in reply to change case
What you want is called title case.
Unfortunately, the function associated with it, ucfirst, only does its magic on the first letter of the string, not the first letter of each word.
Try
to do what you want.join ' ' , map ucfirst, split ' '
Like with upper case, the character escape for title case is \u. It has the same problem as ucfirst above.
Edit:
Never EVER use tr/a-z/A-Z/ for any uppercasing stuff. It doesn't play well with unicode. Not that you were going to, but it's always good to check.
And it looks like davido beat me. Oh well. I must note, though, that I think my solution is faster if the string is especially long, espectially if the words are deliminated by a single space. Then no regex work needs to be done. ;)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: change case
by davido (Cardinal) on Nov 26, 2003 at 03:18 UTC |