in reply to Re: Re: Converting MySQL datetime values to DateTime objects (regex)
in thread Converting MySQL datetime values to DateTime objects
You have to match all of the punctuation in your source string. E.g., to matchmy $when = '2003-07-14 21:39:26.357'; my ( $yr, $mo, $day, $hr, $min, $sec ) = ( $when =~ /(\d{4})(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)/ );
you would usemy $when = '2003-07';
Fixing the complete regex is a variation on this theme.my ($yr,$mo) = $when =~ /^(\d\d\d\d)-(\d\d)/; ^
|
|---|