Could also use a more robust regex if desired (trivial example is /(200[012345])(\d{4})/) and depending on context.my $string = '20050516'; my $newstring; $newstring = $2 . $1 if $string =~ /(\d{4})(\d{4})/; warn $newstring; (my $newstring = $string) =~ s/(\d{4})(\d{4})/$2$1/; warn $newstring;
In reply to Re: rearranging a string.new
by davidrw
in thread rearranging a string.new
by drock
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |