Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Help required on understanding regular expressions

by NetWallah (Abbot)
on Feb 20, 2012 at 07:49 UTC ( #954999=note: print w/ replies, xml ) Need Help??


in reply to Help required on understanding regular expressions

The "]" was facing the wrong way, and I don't know why you used the "\k". This one works:

/(?<fname>\w+\b)\s(?<mname>\w+)\s(?<lname>\w+\s).*\[(?<date>[^\]]+)/

            “PHP is a minor evil perpetrated and created by incompetent amateurs, whereas Perl is a great and insidious evil perpetrated by skilled but perverted professionals.”
        ― Jon Ribbens


Comment on Re: Help required on understanding regular expressions
Download Code
Re^2: Help required on understanding regular expressions
by bimleshsharma (Beadle) on Feb 21, 2012 at 06:37 UTC
    I dont understand the code.. /(?<fname>\w+\b)\s(?<mname>\w+)\s(?<lname>\w+\s).*\[(?<date>[^\]]+)/ what it is looking for from string?
      /(?<fname>\w+\b) # Looks for "\w" (Word characters followed by a word +boundary (look up \w and \b) # and creates $+{name} \s(?<mname>\w+)\s # Same thing - Whitespace on both sides (?<lname>\w+\s) # Same thing .*\[(?<date>[^\]]+)/ # looks for "[", followed by anything that is NOT + "]", and populates $+{date}
      All this is in the "perlre" document.

                  “PHP is a minor evil perpetrated and created by incompetent amateurs, whereas Perl is a great and insidious evil perpetrated by skilled but perverted professionals.”
              ― Jon Ribbens

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2014-08-29 13:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (280 votes), past polls