Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Capitalize First Letter of Each Word

by holli (Abbot)
on Jun 30, 2005 at 13:04 UTC ( [id://471293]=note: print w/replies, xml ) Need Help??


in reply to Capitalize First Letter of Each Word

my @a = ( "THIS IS TESTING", "JOE MARCONES", "RESIDENTIAL MAINTENANCE COMPANY", ); s/(?<=\w)(.)/\l$1/g for @a; print join "\n", @a;
Update: replaced \1 by $1 as per tlm's suggestion.


holli, /regexed monk/

Replies are listed 'Best First'.
Re^2: Capitalize First Letter of Each Word
by tlm (Prior) on Jun 30, 2005 at 13:39 UTC

    Small nit: the use of backreferences like \1 in the second clause of s/// is deprecated. E.g.:

    % perl -we '$_="foo"; s/(.)/\1/' \1 better written as $1 at -e line 1.

    the lowliest monk

Re^2: Capitalize First Letter of Each Word
by suaveant (Parson) on Jun 30, 2005 at 14:42 UTC
    Heh... these fonts are bad. When I first read this I saw slash-one dollar-one, and was trying to figure out what the heck you were smoking. Then realized \l was slash-ell... characters aren't exaclty the same but that are really close to it. :)

                    - Ant
                    - Some of my best work - (1 2 3)

      So fix your fonts and stop complaining?

Log In?
Username:
Password:

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

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

    No recent polls found