vjvalor has asked for the wisdom of the Perl Monks concerning the following question:
Hello monks,
My regular expression for time-of-day is not working as expected.
Regular expression below is matching "99:02 pm" which is incorrect. What went wrong?
@a = ("9:17 am", "12:30 pm", "99:02 pm", "99:99 pm"); foreach $i (@a) { print "$i\n" if($i =~ /(1[012]|[1-9]):([0-5][0-9]).([aApP][mM])/); }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: regular expression for "time-of-day" is not working
by moritz (Cardinal) on Apr 05, 2012 at 09:43 UTC | |
by vjvalor (Initiate) on Apr 05, 2012 at 09:54 UTC | |
Re: regular expression for "time-of-day" is not working
by DrHyde (Prior) on Apr 05, 2012 at 09:58 UTC | |
by vjvalor (Initiate) on Apr 05, 2012 at 12:02 UTC | |
Re: regular expression for "time-of-day" is not working
by choroba (Cardinal) on Apr 05, 2012 at 09:43 UTC | |
Re: regular expression for "time-of-day" is not working
by Anonymous Monk on Apr 05, 2012 at 18:54 UTC |
Back to
Seekers of Perl Wisdom