($str = lc $str) =~ s{ (?: ^ | \b (?! (?:and|an?|the|o[rfn]) \b ) ) (\w) }{\u$1}gx;