I have a string like this:
$a = "Mike , Tree ";
I want to reverse it to "Tree, Mike".
Is there any function to do that?
Split the string into two strings, flip them, and rejoin them.
Or, use a regex:
$a =~ s/(.+),(.+)/\2,\1/g;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With