Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
Don't ask to ask, just ask
 
PerlMonks  

Re: regular expression for "time-of-day" is not working

by moritz (Cardinal)
on Apr 05, 2012 at 09:43 UTC ( #963629=note: print w/ replies, xml ) Need Help??


in reply to regular expression for "time-of-day" is not working

The regex matches 9:02 pm, and since you haven't anchored it, the regex match comes out true even if it didn't match the whole string. Use at least a word boundary:

/\b(1[012]|[1-9]):([0-5][0-9]).([aApP][mM])\b/

See perlretut and perlre for more details.


Comment on Re: regular expression for "time-of-day" is not working
Select or Download Code
Re^2: regular expression for "time-of-day" is not working
by vjvalor (Initiate) on Apr 05, 2012 at 09:54 UTC
    Thank you moritz.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (13)
As of 2014-04-24 11:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (565 votes), past polls