in reply to Matching Date

Other Monks have provided solutions to your problem but your OP and some of the replies would, IMHO, be more readable given an alternative choice of regular expression delimiter. Instead of

$date =~ /(\d\d?)\/(\d\d?)\/(\d{4})/;

I would prefer

$date =~ m{(\d\d?)/(\d\d?)/(\d{4})};

to avoid having to keep escaping the date separators.

Cheers,

JohnGG

Replies are listed 'Best First'.
Re^2: Matching Date
by Anonymous Monk on Oct 13, 2006 at 15:31 UTC
    here it is:
    if ($date=~/^(\d{1})\/(\d{2})\/(\d{4})$/g){ + $date="0".$1."\/".$2."\/".$3; + print "<br>L1 - $date<br>"; }elsif($date=~/^(\d{2})\/(\d{1})\/(\d{4})/g){ + $date=$1."\/0".$2."\/".$3; + + print "<br>L2 - $date<br>"; }elsif($date=~/^(\d{1})\/(\d{1})\/(\d{4})/g){ + $date="0".$1."\/0".$2."\/".$3; }else{ $date=$date; + }