in reply to help with a regexp
Regexp?
$ perl -e '$_ = "xoxo";$_=ucfirst(reverse(ucfirst(reverse($_))));print +' [download]
Yes, this _is_ faster than any regular expression.