str.title question after '

2006-11-13 Thread Antoon Pardon
I have a text in ascii. I use the ' for an apostroph. The problem is this gives problems with the title method. I don't want letters after a ' to be uppercased. Here are some examples: argument result expected 't smidje 'T Smidje 't Smidje na'ama

Re: str.title question after '

2006-11-13 Thread John Machin
Antoon Pardon wrote: I have a text in ascii. I use the ' for an apostroph. The problem is this gives problems with the title method. I don't want letters after a ' to be uppercased. Here are some examples: argument result expected 't smidje 'T Smidje 't

Re: str.title question after '

2006-11-13 Thread Leo Kislov
Antoon Pardon wrote: I have a text in ascii. I use the ' for an apostroph. The problem is this gives problems with the title method. I don't want letters after a ' to be uppercased. Here are some examples: argument result expected 't smidje 'T Smidje 't

Re: str.title question after '

2006-11-13 Thread Fredrik Lundh
Leo Kislov wrote: Is there an easy way to get what I want? def title_words(s): words = re.split('(\s+)', s) return ''.join(word[0:1].upper()+word[1:] for word in words) nit: to work well also for Unicode strings using arbitrary alphabets, you should use title() instead of upper().