This is exactly why we have \b

consider the following:

$_ = "hello world. goodbye    cruel       world";

s/\b(.)/uc$1/seig;

print;

####

this should do exactly what you want... it matches the first character after
a word boundary and uppercases it.

there's an explenation about regexes at the tutorials section on my site,
that has plenty of examples of such things
take a look if you're interested, at http://japh.nu

regards,

Jos Boumans


> Hello All,
>
> how can i convert only the first letter of each word
> in a string without changing any other characters?
> Is this a job for regular expressions?
>
> For example, convert:
>
> FROM: "hello world. goodbye    cruel       world"
>
> TO:   "Hello World. Goodbye    Cruel       World"
>
> any help is appreciated.
>
> --sal
>
>



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to