At 20.04 1/6/98, Ken Cartner (News) wrote: >I'm trying to change words that are in all upercase to upper and lower. >And i can'rt seem to come up with a logical way to achieve this. > >Here's my problem... I'm writing a script for our sports section to >process the NBA boxscores for publication. > >Far too often AP sends words in the file in all uppercase and we change >them. For example: L.A. LAKERS, PHILADELPHIA, SAN ANTONIO. Iturned >everythig to lowercase with "tr" But now I can't seem to come up with a >search that will only change the first letter of a word. > >Any ideas? > >I've been trying, in a while statement, to change every lowercase char >that isn't preceded by another lowercase char or uppercase char to >uppercase. (Since the first letter of each word would be at the begining >of the string or preceded by a space, comma or period. I figured that >would work, but I end up changing every char. to uppercase. > >Any help would be greatly appreciated. Thanks. NOTE: This is not a MacPerl question, but a general Perl question. Not a big problem unless it happens too often, I suppose. Maybe this will do what you want: $x = 'L.A. LAKERS, PHILADELPHIA, SAN ANTONIO'; $x = lc($x); # what you did $x =~ s/\b(\w)/uc($1)/eg; print $x,"\n"; The regex finds every alphanumeric that follows a word boundary and uppercases it (the /e forces an eval of the replacement section of the regex). So it prints: L.A. Lakers, Philadelphia, San Antonio -- Chris Nandor pudge@pobox.com http://pudge.net/ %PGPKey=('B76E72AD',[1024,'0824 090B CE73 CA10 1FF7 7F13 8180 B6B6']) #== MacPerl: Power and Ease ==# #== Publishing Date: Early 1998. http://www.ptf.com/macperl/ ==# ***** Want to unsubscribe from this list? ***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch