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

Re: A regular expression that will work for (hh:)mm:ss [converting clock time to seconds]

by Riales (Hermit)
on Apr 13, 2012 at 00:35 UTC ( #964845=note: print w/replies, xml ) Need Help??


in reply to A regular expression that will work for (hh:)mm:ss [converting clock time to seconds]

You want the ? which allows 0 or 1 occurrence of the preceding element.

my $timeRegex = '((?:[0-1][0-9]:)?[0-5][0-9]:[0-5][0-9])';
  • Comment on Re: A regular expression that will work for (hh:)mm:ss [converting clock time to seconds]
  • Select or Download Code

Replies are listed 'Best First'.
Re^2: A regular expression that will work for (hh:)mm:ss [converting clock time to seconds]
by aware74 (Initiate) on Apr 13, 2012 at 16:08 UTC

    Thank you. This is what happens when you don't fully understand the regex that is generated for you.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://964845]
help
Chatterbox?
[Corion]: And I think it's better to generate links to the new world instead of keeping the older links alive by generating new versions of them ;)
[marto]: yeah, I guess it's supposed to be a permanent redirect, but better to make the move where possible

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (8)
As of 2018-05-23 09:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?