I've got:
$string =~ s/(\w+)/\u\L$1/g;
Which capitalizes each word in the string. The problem is if I have a string with an apostrophe the first letter after it gets capitalized as well.
So Bob's becomes Bob'S.
Thanks for any quick fixes!
I've got:
$string =~ s/(\w+)/\u\L$1/g;
Which capitalizes each word in the string. The problem is if I have a string with an apostrophe the first letter after it gets capitalized as well.
So Bob's becomes Bob'S.
Thanks for any quick fixes!
Hello,
Try this
gaurav@localhost:~$ perl -wlp -e 's/(\S+)/\u\L$1/g;' <<< "Bob's gone to market"
Bob's Gone To Market
gaurav@localhost:~$
Regards,
Gaurav.
Ah.... \S = any non-whitespace character!
Super... thank you very kindly!
Only \u is enough...
echo "Bob's gone to market" | perl -wlp -e 's/(\S+)/\u$1/g;'
Hello,
No only \u is not enough as we dont want something like this. ->
gaurav@localhost:~$ perl -wlp -e 's/(\S+)/\u$1/g;' <<< "BOb's goNe tO maRkEt"
BOb's GoNe TO MaRkEt
gaurav@localhost:~$
Regards,
Gaurav.