Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

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.

Comment on RE: RE: Re: $1
Download Code
Replies are listed 'Best First'.
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?

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2015-11-26 00:51 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (695 votes), past polls