Q:

PHP - String pattern matching

I need to know if there is any way I can do the following using regular expressions (or otherwise) in PHP

aaBaa BBB -> aa Baa BBB

ie, I want to introduce a space before a capital letter only if a Capital letter occurs before and after a small letter.  
The best I could come up with was something like this
$string = preg_replace('/(\w+)([A-Z])/U', '\\1 \\2', $string);

but that would only give me something like

aaBaa BBB -> aa Baa B B B

Thanks in advance. 

A:

Here: http://rubular.com/r/3xqbuWuiLD
([a-z]+)([A-Z]+)

