On Apr 12, 11:10 pm, shlomit.af...@weizmann.ac.il ("Shlomit Afgin") wrote: > Hi > > I need to write regular expression that will capitalize the first letter of > each word in the string. > Word should be string with length that is greater or equal to 3 letters > exclude the words 'and' and 'the'. > > I tried: > $string = lc($string); > $string =~ s/\b(\w{3,}[(^the|^and)])\b/ucfirst($1)/ge;
A character class is the wrong strategy. For more details about how character classes, see: perldoc perlretut Another possible solution: s/\b(\w{3,})/ucfirst( lc $1)/ge; -- Charles DeRykus -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/