How can I reorder substrings in a string?
perl, regex
Solution
use strict;
use warnings;
use v5.10;
my $date = "2009-27-02";
$date =~ s/(\d{4})-(\d{2})-(\d{2})/$1-$3-$2/;
say $date;
Problem
How do I do the following conversion in regex in Perl? ``` British style US style "2009-27-02" => "2009-02-27" ``` I am new to Perl and don't know much about regex, all I can think of is to extract different parts of the "-" then re-concatenate the string, since I need to do the conversion on the fly, I felt my approach will be pretty slow and ugly.