On 2014-02-03 21:30, Paul Fontenot wrote:
Hi, I am attempting to write a regex but it is giving me a headache.

I have two log entries

1. Feb  3 12:54:28 cdrtva01a1005 [12: 54:27,532] ERROR
[org.apache.commons.logging.impl.Log4JLogger]
2. Feb  3 12:54:28 cdrtva01a1005 [12: 54:27,532] ERROR [STDERR]

I am using the following
"^\w+\s+\d{1,2}\s+\d{1,2}:\d{1,2}:\d{1,2}\s+\w+\s+\[\d{1,2}:\s+\d{1,2}:\d{1,
2},\d{3}\]\s+\w+\s+\[[a-zA-Z0-9.]\]"

My problem is this greedy little '.' - I need to just be a period. How do I
match #1 and not match #2?


I think you should replace "\[[a-zA-Z0-9.]\]" by "\[[^]]+\]".

Don't worry of matching, see this as parsing, and skip a line on how it matches, not on how it doesn't match.

Hint: start using "named captures".

If you are into massively scanning log files, try MCE::Grep.

--
Ruud


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to