Re: Separating words based on capital letter

From: Date: Wed, 25 Apr 2007 14:37:35 +0000
Subject: Re: Separating words based on capital letter
References: 1 2 3 4 5  Groups: php.general 
Request: Send a blank email to php-general+get-253715@lists.php.net to get a copy of this message
Note: several of the folks used "/" as the delimiter. Actually, it can be almost anything that will not be in the $string. Generally, I use "%" simply because it's easier to spot when I forget the delimiters. Also, note Robin's use of the metachar [[:upper:]]. metacharacters can very useful. My favorites are [:punct:] and [:space:] Dotan Cohen wrote:
On 25/04/07, Robin Vickery <robinv@gmail.com> wrote:
$string = preg_replace('/(?<=\w)([[:upper:]])/', ' $1', $string); turns "this is OpenSourceCode" to "this is Open Source Code"
Another great solution, Robin, thanks. I've learned a LOT from this thread. Dotan Cohen http://what-is-what.com/what_is/open_office.html http://hardtofindlyrics.com


« previous php.general (#253715) next »