in reply to Re^2: Regex Substitution Evaluations
in thread Regex Substitution Evaluations

I think pc88mxer answered your question for the most part.

$my_name = replace("august ferdinand mobius","\b(\w)","\U$1","igs"); # Becomes something more like... $my_name = replace("august ferdinand mobius", qr/(?igs)\b(\w)/, '\U$1' +);

Update: You should consider that your solution will not work for a variety of names, like mccleod, vomdorp, decaro, etc. For proper names, a dictionary (with the right library under it, like proper names) is a better way to go, and there is no perfect solution since the same spellings are sometimes capitalized differently. :(

Replies are listed 'Best First'.
Re^4: Regex Substitution Evaluations
by oko1 (Deacon) on Jul 05, 2008 at 22:31 UTC

    I gave a few examples, more-or-less off the top of my head, in an article I wrote a number of years ago, when I was talking about the inadvisability of assumptions when it came to names:

    John deJongh
    Jan M. van de Geijn
    Kathleen O'Hara-Mears
    Siu Tim Au Yeung
    Nang-Soa-Anee Bongoj Niratpattanasai
    Mjölby J. de Waærn
    

    Also, assuming things about the order of, say, Chinese or Indian names is likely to run into problems - even within a given city, in the latter case.

    
    -- 
    Human history becomes more and more a race between education and catastrophe. -- HG Wells
    
Re^4: Regex Substitution Evaluations
by mobiusinversion (Beadle) on Jul 07, 2008 at 18:53 UTC
    The names problem is interesting, although I'm sort of kicking myself for giving it as an example. The motivation for this post was and is to develop a general substitution framework for parametrized regex creation...