in reply to Re: Title Case One-Liner
in thread Title Case One-Liner

I suggest s/([^\s\w]*)(\S+)/$1\u\L$2/g; instead. It treats things like q{"not a question" folks} (which becomes q{"Not A Question" Folks}).

japhy -- Perl and Regex Hacker

Replies are listed 'Best First'.
Re: Re: Re: Title Case One-Liner
by chipmunk (Parson) on Feb 10, 2001 at 02:44 UTC
    The trick there is making sure the first character is a word character. Here's a shorter version of the same thing: s/(\w\S*)/\u\L$1/g;
Re: Re: Re: Title Case One-Liner
by MeowChow (Vicar) on Feb 10, 2001 at 03:38 UTC
    Nice, but both this and chipmunk's can't handle "just,another,list,of,words" (ie. punctuation without spaces)... why not just:
    s/(\w+)/\u\L$1/g;
    Update: eating self-served humble pie, never mind, this can't deal with "i promise i won't shouldn't can't reply without thinking..." :)