| | |
Regular expression
![]() |
•
•
Join Date: Jan 2005
Posts: 2
Reputation:
Solved Threads: 0
Hi there,
Does any one know a Perl regular expresson to ignore specific string from a log file.
For example i want to use this simple unix command using perl regular expression
egrep -i -n "error|fatal" logfile.log |\egrep -v "user not found"
i.e. it should ignore log file entry "Error user not found" but at the same time if log file contains "error script fails" it should detect "error".
Thanks in advance.
Does any one know a Perl regular expresson to ignore specific string from a log file.
For example i want to use this simple unix command using perl regular expression
egrep -i -n "error|fatal" logfile.log |\egrep -v "user not found"
i.e. it should ignore log file entry "Error user not found" but at the same time if log file contains "error script fails" it should detect "error".
Thanks in advance.
•
•
•
•
Originally Posted by Nihar
Hi there,
Does any one know a Perl regular expresson to ignore specific string from a log file.
For example i want to use this simple unix command using perl regular expression
egrep -i -n "error|fatal" logfile.log |\egrep -v "user not found"
i.e. it should ignore log file entry "Error user not found" but at the same time if log file contains "error script fails" it should detect "error".
Thanks in advance.
Perl Syntax (Toggle Plain Text)
if(/error script fails/i) { next if(/Error user not found/i); }
•
•
Join Date: Jan 2005
Posts: 2
Reputation:
Solved Threads: 0
here is the log file content
365:[2005-02-10 10:43:39,499][testapi][INFO ][Servlet.Engine.Transports : 252][service.BaseService] - ApplRef: null Error -NXFB=(8;701) user not found in database.
370:[2005-02-10 10:43:47,955][testapi][ERROR][Servlet.Engine.Transports : 41][OLDLOGGING] - - E - - - User does not have the
required access level for this application.
The first line should be ignored eventhough it contents sring "Error".
but the second line should raise a flag because it does not content string "user not found in database"
i believe it's clear now. I'm looking for regular expression to parse this kinda log file. i can simply use egrep and egrep-v but that's not the solution i cna use here.
365:[2005-02-10 10:43:39,499][testapi][INFO ][Servlet.Engine.Transports : 252][service.BaseService] - ApplRef: null Error -NXFB=(8;701) user not found in database.
370:[2005-02-10 10:43:47,955][testapi][ERROR][Servlet.Engine.Transports : 41][OLDLOGGING] - - E - - - User does not have the
required access level for this application.
The first line should be ignored eventhough it contents sring "Error".
but the second line should raise a flag because it does not content string "user not found in database"
i believe it's clear now. I'm looking for regular expression to parse this kinda log file. i can simply use egrep and egrep-v but that's not the solution i cna use here.
•
•
•
•
Originally Posted by Schwallex
How about just parsing for [ERROR]?
Perl Syntax (Toggle Plain Text)
if($line =~ /\[ERROR\]/) { print "It contains error\n"; }
![]() |
Similar Threads
- Regular Expression (Perl)
- How to write javascript regular expression for this case? (JSP)
- regular expression (PHP)
- Regular Expression Matching New Line (Perl)
- Looking for table rows with Regular expression. (PHP)
Other Threads in the Perl Forum
- Previous Thread: where to start with perl?
- Next Thread: Beginner question: need help importing tab-delimited file as perl hash
| Thread Tools | Search this Thread |






