in reply to Re^2: Trouble with regular expression
in thread Trouble with regular expression

Indeed a missing "(": I blame it on my less than perfect "copy-and-paste"-fu!

\d+ works, but as a general rule in a regex one should try to be as restrictive as possible, in order for the regex to pass only what is exactly right. For instance, \d+ allows something like "123456789" for any of the elements and that is surely wrong.

By the same token, \d{2} isn't perfect either as it allows "99" for the number of months, days, hours, minutes or seconds.

Regexp::Common::time has the following regex for the number of months:

/(?:(?=[01])(?:0[1-9]|1[012]))/
That regex does not allow "wrong" numbers for the month and there are similar regexen for days, hours, ...

In the end it all comes down to how much you trust your input to do no funny things.

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James