I just can't see where the problem is, and why today's date is matching on L1
Why shouldn't it? It has a number followed by a slash and then 2 numbers... Maybe you want to anchor the regex to the beginning and end of the string?:
my @dates = qw| 10/13/2006 1/13/2006 10/1/2006 1/1/2006 |; foreach my $date (@dates) { if ($date =~ m|^(\d{1,2}) / (\d{1,2}) / (\d{4})$|x) { ## <-- anc +horing $date = sprintf "%02d/%02d/%04d", $1, $2, $3; } print "result: <$date>\n"; } __END__ result: <10/13/2006> result: <01/13/2006> result: <10/01/2006> result: <01/01/2006>
Update: Typo fix.
--
David Serrano
In reply to Re: Matching Date
by Hue-Bond
in thread Matching Date
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |