GIAC
GPYC · Question #43
Which regular expression will match all date-time stamps for log files of the format shown in the screen capture? Mon May 9 23:13:37.379 <kernel> AWDL Sync Enabled 0 Mon May 9 23:13:41.513 <kernel>…
The correct answer is B. re.findall(r"w\w{3}\W(\d){1,2}\W(\d){2}\W(\d){2}\W(\d){3}", file.read()). You've hit your limit · resets 1pm (America/New_York)
Web Scraping & Forensics with Python
Question
Which regular expression will match all date-time stamps for log files of the format shown in the screen capture?
Mon May 9 23:13:37.379 <kernel> AWDL Sync Enabled 0
Mon May 9 23:13:41.513 <kernel> AWDL Sync Enabled 0
Mon May 9 23:37:33.910 <kernel> w10: leaveModulePoweredFor0ffloads:
turn off.
Mon May 9 23:37:33.931 <airportd[58]> _handleLinkEvent: WiFi is not
setting state variables.
Mon May 9 23:37:33.937 <kernel> AWDL Sync Enabled 0
Mon May 9 23:55:21.072 <kernel> AWDL Sync Enabled 0
Mon May 9 23:57:21.249 <kernel> w10: leaveModulePoweredFor0ffloads:
turn off.
Mon May 9 23:57:21.274 <airportd[58]> _handleLinkEvent: WiFi is not
setting state variables.
Mon May 9 23:57:21.279 <kernel> AWDL Sync Enabled 0
Tue May 10 02:57:23.952 <kernel> AWDL Sync Enabled 0
Tue May 10 07:57:58.361 <kernel> w10: leaveModulePoweredFor0ffloads:
turn off.
Tue May 10 07:57:58.435 <kernel> AWDL Sync Enabled 0
<kernel> w10: leaveModulePoweredFor0ffloads: Wi-Fi will turn off.
Tue May 10 09:29:27.031 <kernel> AWDL Sync Enabled 0
Tue May 10 09:30:00.106 <kernel> AWDL Sync Enabled 0
Tue May 10 09:30:00.669 <kernel> AWDL Sync Enabled 0
Tue May 10 09:30:42.550 <airportd[58]> _handleLinkEvent: Got an error
query WiFi for power. Resetting state variables.
Options
- Are.findall(r"w\W\w|+(\d){2}\W(\d){2}\W(\d){2}\W(\d){3}", file.read())
- Bre.findall(r"w\w{3}\W(\d){1,2}\W(\d){2}\W(\d){2}\W(\d){3}", file.read())
- Cre.findall(r"\w\W|\w+(\d){1,2}\W(\d){1,2}\W(\d){1,2}\W(\d){1,3}", file.read())
- Dre.findall(r"\W\W|\w+\d|\W:\d:\d:\d|\d", file.read())
How the community answered
(32 responses)- A3% (1)
- B66% (21)
- C13% (4)
- D19% (6)
Explanation
You've hit your limit · resets 1pm (America/New_York)
Topics
#regex#log parsing#re.findall#timestamp pattern
Community Discussion
No community discussion yet for this question.