On 2017-03-05 03:40 PM, Terry Reedy wrote:
import re
def title(string):
return re.sub(r"\b'\w", lambda m: m.group().lower(), string.title())
Nice. It lowercases a word char that follows an "'" that follows a word
without an intervening non-word char. It passes this test:
print(title("'time' isn't 'timeless'!"))
'Time' Isn't 'Timeless'!
It guess the reason not to bake this exception into str.title is that it
is language specific and could even be wrong if someone used "'" to
separate words (perhaps in a different alphabet).
Or, it doesn't handle exceptions.
print title("My name is D'Arcy")
Oops.
--
D'Arcy J.M. Cain
Vybe Networks Inc.
http://www.VybeNetworks.com/
IM:da...@vex.net VoIP: sip:da...@vybenetworks.com
--
https://mail.python.org/mailman/listinfo/python-list