I have a set of strings from a log file that I need to parse:
timestamp - user not found : user1
timestamp - exception in xyz.security.plugin: global error : low memory
I want to capture the text between “-” and the last “:”.
Currently I am using r’ -(.*?)\n’ which captures the string till the EOL. Please bear in mind that there may be more than 2 colons used in the string. I need to capture till the very last colon used before EOL.
Also, if there are no “:” colons in the string, it should take EOL as the ending sequence.
thanks.
EDIT: better examples;
2011-07-29 07:29:44,112 [TP-Processor10] ERROR springsecurity.GrailsDaoImpl - User not found: sspm
2011-07-29 09:01:05,850 [TP-Processor3] ERROR transaction.JDBCTransaction - JDBC commit failed
2011-07-29 08:32:00,353 [TP-Processor1] ERROR errors.GrailsExceptionResolver - Exception occurred when processing request: [POST] /webapp/user/index - parameters: runtime exception
1 Answer