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

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



Chris Nandor writes:
|$x = "Some teams like L.A. LAKERS, PHILADELPHIA, and SAN ANTONIO for the
|purpose of this exercise.\n";
|$x =~ s/\b([A-Z]\w+)\b/ucfirst(lc($1))/ge;
|print $x,"\n";

With escapes, you can avoid the cost of evaluating an expression for
every substitution:

$x = "Some teams like L.A. LAKERS, PHILADELPHIA, and SAN ANTONIO for the purpose of this exercise.\n";
$x =~ s/\b([A-Z]\w+)/\L\u$1\E/g;
print $x, "\n";

Of course, you don't want any stories about IBM or DEC...

Brian

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