Re: Separating words based on capital letter

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

 



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@xxxxxxxxx> 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

--
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