[PLUG] reg. ex.
Dave Jacoby
jacoby@ecn.purdue.edu
Thu, 2 Sep 1999 09:43:34 -0500 (EST)
On Thu, 2 Sep 1999, Brent Meshier wrote:
>Hey, someone on this list was helping me with regular expressions last year,
>and I have another question. I think it might have been Dave? Anyhow, if
>that person could contact me, I'm looking for an expression that will
>capitalize the first letter of each word in a sentence and lowercase
>everything else.
s/(\w+)/\L\u$1/g
This is perl's regex. It might have to change for anything else.
(\w)+ grabs a thing that is all word characters [A-Za-z_] and puts
them into the $1 of the second part. \L forces everything after to be
lower case. \u forces the next letter to be upper case. There is a
closing character, but I forgot what it is. You don't need it here,
because the changes only occur within the s///.
>--Brent
--
David Jacoby mailto:jacoby@ecn.purdue.edu
Lead Web Technician, ECE http://www.ecn.purdue.edu/~jacoby/
Payin' the bills with my mad programming skills
---------------------------------------------------------------