Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

RE: RE: Re: $1

by Ted Nitz (Chaplain)
on Jun 21, 2000 at 19:38 UTC ( #19257=note: print w/ replies, xml ) Need Help??


in reply to RE: Re: $1
in thread $1

I like that regex more, but there are still a few minor changes I would make.

while (<>){ if(/ ( [0-3]?[0-9](?:th|st|nd|rd)?\s+ # Get day (?: # Get month Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?| Apr(?:il)?|May|Jun(?:e)?|Jul(?:y)?| Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?| Nov(?:ember)?|Dec(?:ember)? )\s+ [0-9]{2,4} # Get Year ) /ix) { print "$1\n"; } }
The (?:) things are just like normal ()'s except they don't capture to a variable, they just do grouping, helps the interpreter optimize the regex.

The {x,y} means require atleast x of the previous item, and at most y. For refrence you can also say {x} which means require x of them, or {x,} which means atleast x.
-Ted


Comment on RE: RE: Re: $1
Download Code
RE: RE: RE: Re: $1
by Odud (Pilgrim) on Jun 21, 2000 at 22:34 UTC
    Oh I agree entirely - it was a just a quick solution to the problem, not an attempt at an optimal one. There's a date parser module available through CPAN which I would normally use. I don't know if it copes with 2nd, 4th, etc. though.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2014-11-22 21:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (125 votes), past polls