Sorry, that last line was wrong... my $in = '000007032003'; $in =~ s/^0+/$1/ if (/(\d{2})(\d{2})(\d{4})$/);
# my $out = qq($in/$2/$3); yuck, sorry # Now we can do the replacement with no problem # because we've restructured $in to dd/dd/dddd my $out = qq($1/$2/$3) if (/(\d{2})(\d{2})(\d{4})/); -----Original Message----- From: Scot Robnett [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 02, 2003 2:03 PM To: Paul Kraus; Sara; [EMAIL PROTECTED] Subject: RE: Regex question. > > 2- Want to format dates like birth = 02151956 should be 02/15/1956 > my $date = "$1/$2/$3/" if (/(\d\d)(\d\d)(\d\d\d\d)/) # All of this is UNTESTED, please treat as such. # More of "the same but different" my $date = qq($1/$2/$3) if /(\d{2})(\d{2})(\d{4})/; # Takes into account dates like 07/03/2003, unless # of course you've lopped off the preceding "000" type # strings with s/^0+//; --- for example: my $in = '000007032003'; my $out = qq($1/$2/$3) if /(\d{2})(\d{2})(\d{4})/; print $out; # would result in printing: # 00/00/0703 # This might work better (preserving preceding "0" on the date) my $in = '000007032003'; $in =~ s/^0+/$1/ if (/(\d{2})(\d{2})(\d{4})$/); my $out = qq($in/$2/$3); -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]