Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Log regexp

by toolic (Bishop)
on Aug 03, 2012 at 13:51 UTC ( #985242=note: print w/ replies, xml ) Need Help??


in reply to Log regexp

I think this is the problem: \"\S+\"

Maybe these tools will help:

  • The Perl Regex Tester
  • YAPE::Regex::Explain ... Tip #9 from the Basic debugging checklist
    The regular expression: (?-imsx:^(\S+)\, (\S+) (\S+) \- \- \[(\d{2})/(\w+)/(\d{4})\:(\d{2})\:( +\d{2})\:(\d{2})\+(\d{4})\] \"\S+\" (\d{3}) (\d+|-) \"(.*?)\" \"\.*?\" +$) matches as follows: NODE EXPLANATION ---------------------------------------------------------------------- (?-imsx: group, but do not capture (case-sensitive) (with ^ and $ matching normally) (with . not matching \n) (matching whitespace and # normally): ---------------------------------------------------------------------- ^ the beginning of the string ---------------------------------------------------------------------- ( group and capture to \1: ---------------------------------------------------------------------- \S+ non-whitespace (all but \n, \r, \t, \f, and " ") (1 or more times (matching the most amount possible)) ---------------------------------------------------------------------- ) end of \1 ---------------------------------------------------------------------- \, ',' ---------------------------------------------------------------------- ' ' ---------------------------------------------------------------------- ( group and capture to \2: ---------------------------------------------------------------------- \S+ non-whitespace (all but \n, \r, \t, \f, and " ") (1 or more times (matching the most amount possible)) ---------------------------------------------------------------------- ) end of \2 ---------------------------------------------------------------------- ' ' ---------------------------------------------------------------------- ( group and capture to \3: ---------------------------------------------------------------------- \S+ non-whitespace (all but \n, \r, \t, \f, and " ") (1 or more times (matching the most amount possible)) ---------------------------------------------------------------------- ) end of \3 ---------------------------------------------------------------------- ' ' ---------------------------------------------------------------------- \- '-' ---------------------------------------------------------------------- ' ' ---------------------------------------------------------------------- \- '-' ---------------------------------------------------------------------- ' ' ---------------------------------------------------------------------- \[ '[' ---------------------------------------------------------------------- ( group and capture to \4: ---------------------------------------------------------------------- \d{2} digits (0-9) (2 times) ---------------------------------------------------------------------- ) end of \4 ---------------------------------------------------------------------- / '/' ---------------------------------------------------------------------- ( group and capture to \5: ---------------------------------------------------------------------- \w+ word characters (a-z, A-Z, 0-9, _) (1 or more times (matching the most amount possible)) ---------------------------------------------------------------------- ) end of \5 ---------------------------------------------------------------------- / '/' ---------------------------------------------------------------------- ( group and capture to \6: ---------------------------------------------------------------------- \d{4} digits (0-9) (4 times) ---------------------------------------------------------------------- ) end of \6 ---------------------------------------------------------------------- \: ':' ---------------------------------------------------------------------- ( group and capture to \7: ---------------------------------------------------------------------- \d{2} digits (0-9) (2 times) ---------------------------------------------------------------------- ) end of \7 ---------------------------------------------------------------------- \: ':' ---------------------------------------------------------------------- ( group and capture to \8: ---------------------------------------------------------------------- \d{2} digits (0-9) (2 times) ---------------------------------------------------------------------- ) end of \8 ---------------------------------------------------------------------- \: ':' ---------------------------------------------------------------------- ( group and capture to \9: ---------------------------------------------------------------------- \d{2} digits (0-9) (2 times) ---------------------------------------------------------------------- ) end of \9 ---------------------------------------------------------------------- \+ '+' ---------------------------------------------------------------------- ( group and capture to \10: ---------------------------------------------------------------------- \d{4} digits (0-9) (4 times) ---------------------------------------------------------------------- ) end of \10 ---------------------------------------------------------------------- \] ']' ---------------------------------------------------------------------- ' ' ---------------------------------------------------------------------- \" '"' ---------------------------------------------------------------------- \S+ non-whitespace (all but \n, \r, \t, \f, and " ") (1 or more times (matching the most amount possible)) ---------------------------------------------------------------------- \" '"' ---------------------------------------------------------------------- ' ' ---------------------------------------------------------------------- ( group and capture to \11: ---------------------------------------------------------------------- \d{3} digits (0-9) (3 times) ---------------------------------------------------------------------- ) end of \11 ---------------------------------------------------------------------- ' ' ---------------------------------------------------------------------- ( group and capture to \12: ---------------------------------------------------------------------- \d+ digits (0-9) (1 or more times (matching the most amount possible)) ---------------------------------------------------------------------- | OR ---------------------------------------------------------------------- - '-' ---------------------------------------------------------------------- ) end of \12 ---------------------------------------------------------------------- ' ' ---------------------------------------------------------------------- \" '"' ---------------------------------------------------------------------- ( group and capture to \13: ---------------------------------------------------------------------- .*? any character except \n (0 or more times (matching the least amount possible)) ---------------------------------------------------------------------- ) end of \13 ---------------------------------------------------------------------- \" '"' ---------------------------------------------------------------------- ' ' ---------------------------------------------------------------------- \" '"' ---------------------------------------------------------------------- \.*? '.' (0 or more times (matching the least amount possible)) ---------------------------------------------------------------------- \" '"' ---------------------------------------------------------------------- $ before an optional \n, and the end of the string ---------------------------------------------------------------------- ) end of grouping ----------------------------------------------------------------------


Comment on Re: Log regexp
Select or Download Code
Replies are listed 'Best First'.
Re^2: Log regexp
by kazak (Beadle) on Aug 06, 2012 at 09:16 UTC
    Thx for help, I'll use this.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://985242]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2015-07-30 06:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (270 votes), past polls