[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Change "WORD" to "Word"



On Wed, 7 Jan 1998 10:37:55 -0800 (PST), you wrote:

>Bart Lateur writes:
>|>I'm trying to change words that are in all upercase to upper and lower.
>|I've noticed a lot of solutions to this problem already, but none looks
>|as simple as mine. So here goes:
>|	s/(\w+)/\u\L$1/g;
>
>That capitalizes the first letter of *every* word. You have to look for
>an uppercase letter at the start of the word:
>
>s/\b([A-Z]\w+)/\L\u$1\E/g;

You want to apply the substitution to the whole sentence, not just the
names? That's silly. But anyway, your method doesn't work if a word
starts with a lowercase (by accident), and contains uppercase letters
(like "pHILADELPHIA").

Still, I think it's simpler to change the case to lower case for every
letter in a word but leaving the first as it was.

	s/(\w)(\w+)/$1\L$2/g;

	Bart.

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch