Re: Regex for ... genealogical names

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 1/1/2011 4:46 AM, Lester Caine wrote:
JohnDoeSMITH' or 'John Doe SMITH'

Try this. not tested.

First, which adds spaces as needed. e.g. JohnDoeSMITH > 'John Doe SMITH'

$newName=preg_replace("%(?<=[a-z])([A-Z])", " $1", $name);//Cap following low
case, add space before it

Next, alphas following a cap, lower case them

function lowCase($matches){return strtolower($matches[1]);}

$newName= preg_replace_callback("%(?<=[A-Z])([A-Z])%", "lowCase', $newName);

Sorry don't have time today to test; but, this should get you started.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux