FAQ

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

Search Discussions

Discussion Posts

Previous

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 3 of 3 | next ›
Discussion Overview
groupbeginners @
categoriesperl
postedFeb 3, '14 at 8:30p
activeFeb 4, '14 at 11:02a
posts3
users3
websiteperl.org

People

Translate

site design / logo © 2021 Grokbase