I need to match the following line using regular expression.
Single lines contain the following things (example):
2010/11/29 09:开发者_如何学编程37:55 (2768)FMS:600 ERROR> Received SIGWARNING: nonstandard use of escape in a string literal
2010/11/29 09:37:55 (2768)FMS:600 ERROR> Received SIGNOTICE: exp: select * from follow_me_switch.call_from_entries where follow_me_group_id in ( select id from follow_me_switch.follow_me_groups where profile_id =105 and follow_me_switch.call_from_entries.call_from_number !~ \'^s*$\'
From those lines I need to match and remove the date and time stamps until the ERROR> How can we match this using efficient regular expression?
Thanks in advance.
Ehm, how about:
^2010\/11\/29 09:39:57 \(2786\)Db_Wrapper\.pm:1404 ERROR\>
But somehow I think, you meant something different...
EDIT: This answer applied to an earlier question, that was later edited.
In case you meant every line that has error in db_wrapper that would be something like
^\d{4}/\d{1,2}/\d{1,2} \d{2}:\d{2}:\d{2} \(\d+\)Db_Wrapper\.pm:\d+ ERROR>
or much easier, just
^.*Db_Wrapper\.pm:\d+ ERROR>
Does this what you want?
^.*?(?=ERROR)
and replace with an empty string
See it here on Regexr
This will match everything till the first ERROR
is ahead.
.*?
is a lazy match that only will match as less as possible
(?=ERROR)
is a positive look ahead that checks when the string ERROR
is next
One more regexp:
^\d{4}/\d{2}/\d{2}\s\d{2}:\d{2}:\d{2}\s\(\d+\)Db_Wrapper\.pm:\d+\sERROR>
精彩评论