I have two date variables that are in "MM/DD/YY" format. I want to sort them properly—by year, month, then day. So currently I have four separate regular expressions to make the change (on account of 03 < 99, even though 2003 > 1999).
$date_a =~ s!(\d{2})/(\d{2})/(9\d)!$3$1$2!; $date_b =~ s!(\d{2})/(\d{2})/(9\d)!$3$1$2!; $date_a =~ s!(\d{2})/(\d{2})/(0\d)!1$3$1$2!; $date_b =~ s!(\d{2})/(\d{2})/(0\d)!1$3$1$2!;
I suspect there's a quicker way to do this. I hope it's the kind of thing I can reuse again, because I see myself having nearly-redundant regular expressions pretty often.
In reply to Combining s/// by kangaroobin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |