print ucwords('1 monkey face');
print ucwords("don't play zone defense against the philadelphia 76-ers");
1 Monkey Face
Don't Play Zone Defense Against The Philadelphia 76-ers
As expected, ucwords( ) doesn't
capitalize the "t" in
"don't." But it
also doesn't capitalize the
"e" in
"76-ers." For ucwords(
), a word is any sequence of nonwhitespace characters that
follows one or more whitespace characters. Since both
' and - aren't
whitespace characters, ucwords( )
doesn't consider the
"t" in
"don't" or the
"e" in
"76-ers" to be word-starting
characters.
Both ucfirst( ) and ucwords( )
don't change the case of nonfirst letters:
print ucfirst('macWorld says I should get a iBook');
print ucwords('eTunaFish.com might buy itunaFish.Com!');
MacWorld says I should get a iBook
ETunaFish.com Might Buy ItunaFish.Com!