Re: Regex for ... genealogical names
| From: | Al | Date: | Sat, 01 Jan 2011 14:46:44 +0000 |
| Subject: | Re: Regex for ... genealogical names | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-310442@lists.php.net to get a copy of this message | ||
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.