Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: RegExp Capitalization of Entry

by insensate (Hermit)
on Jul 16, 2002 at 16:13 UTC ( [id://182136]=note: print w/replies, xml ) Need Help??


in reply to RegExp Capitalization of Entry

Here is a way to do it with one regex:
while(<DATA>){ @words=split; for(@words){ /(?:(the|or|and)|\w+) #Capture "the|or|and" (?(1) #Switch on captured value (?{print"$_ "}) #If there is a captured value just print |(?{print "\u\L$_ "}))#If not convert first char uppercase /x; } } __DATA__ red hot chili peppers, by the way
Hope this helps,
Jason

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://182136]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-24 20:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found