[thelist] Parsing camelcase text

Jack Timmons jorachim at gmail.com
Sun Jan 11 14:47:18 CST 2009

On Sun, Jan 11, 2009 at 2:42 PM, Matt McKeon <matt at camadro.com> wrote:

> I need to separate words that are in CamelCased form. After trying to use
> my
> weak regular expressions skills, I came up with the following half working
> solution: /([A-Z].*)([A-Z].*)/
> That works on a string containing only 2 words, but some strings may
> contain
> more words. Can anyone help modify it to catch any number of words in a
> string? I tried using a look ahead, but couldn't get it quite right.
> I'm doing this in PHP with preg_match().
> Thanks.

preg_match_all() [1] without thinking hard should help

/([A-Z].*?)/ for the regex.

[1] - http://us3.php.net/manual/en/function.preg-match-all.php
-Jack Timmons
Twitter: @jorachim

More information about the thelist mailing list