got a quick question here about regex. I have a file(testlog-date.log) that has lines like this
# 2014-04-09 16:43:15,136|PID: 1371|INFO|Test.Controller.Root|Finished processing request in 0.003355s for https://website/heartbeat
I'm looking to use regex to capture the PID and the time. So far I have this
import re
file_handler = open("testlog-20140409.log", "r")
for line in file_handler:
var1 = re.findall(r'(\d+.\d+)s', line)
print var1
file_handler.close()
So I'm able to print all the process time..question is how do I also capture the PID (and possibly other information into my variable var1? I tried doing this
var1 = re.findall(r'PID: (\d+) (\d+.\d+)s', line)
It prints out empty structures.
Much appreciated Thanks!
Followup: My file is quite large. I'm thinking of storing all the data into one structure and sort them using by process time, and print out the top 20. Any idea how I could do it properly?