Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

RE: RE: Re: $1

by Ted Nitz (Chaplain)
on Jun 21, 2000 at 19:38 UTC ( [id://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

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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2024-04-19 14:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found