On April 27, 2024, our Sign-in and Create Account options will be unavailable from 9am-12pm ET. During this maintenance window, developer account access and free trial registration will be unavailable.

regex help

Ok, so I'm slightly embarassed to be posting a regex help question, but I know one of you beautiful freaks out there can hook me up with a quick answer:

What's the regular expression for making a sentence "Title Case" (a.k.a. Camel Case Like This), if that sentence has an apostrophe in it.

For example, if my $string = "HERE IS A STRING", then this regex:

$string =~ tr/[A-Z]/[a-z]/;
$string =~ s/(\w+)/\u\L$1/g;
will produce "Here Is A String".

But, if my $string = "HERE'S A STRING", the regex above will produce "Here'S A String". (note the capital 'S' after the apostrophe).

Any love out there?

Tom