Jack Timmons wrote: > 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()  without thinking hard should help > > /([A-Z].*?)/ for the regex. > >  - http://us3.php.net/manual/en/function.preg-match-all.php > Trying this with $pattern = "/([A-Z].*?)/"; $string = "MyTestString"; preg_match_all($pattern, $string, $matches); print_r($mathes); Only matches the M, T, and S characters. Which I don't quite understand why. I thought the .*? bit would have caught the next characters, but apparently not.