Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: pattern matching

by mwah (Hermit)
on Nov 22, 2007 at 10:47 UTC ( [id://652348]=note: print w/replies, xml ) Need Help??


in reply to pattern matching

GrandFather already identified the problem in your code; in case you'd like to extend your program to other numerals (1,2,3 - as noted by gangabass), there's another variant:

use strict; use warnings; my $dates = '5th April - 12th April xxxx, ssss, 3rd May - 23th May zzz! 1st June-2nd June, ddd'; my $subexp = qr{ (?:-\s*)? # may be we hit the second term \d+ (?:st|nd|rd|th) # the day \s+\w+\s* # the month }x; my @hits = $dates =~ /$subexp $subexp/xg; print join "\n", @hits;

Regards

mwa

Replies are listed 'Best First'.
Re^2: pattern matching
by chrism01 (Friar) on Nov 23, 2007 at 05:31 UTC
    Not sure I'd count '23th May' as a valid date ;-)
    Cheers
    Chris

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (9)
As of 2024-04-18 14:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found