Regex to space out camel casing

Anyone know a regex to space out a camel casing?

“ThisIsCamelCase” -> “This Is Camel Case”

I don’t need to do any further processing.

Possibly something like this?

$String = trim(preg_replace("/([A-Z])([a-z]*)/", '\\1\\2 ', $String));

Yep, that will do it. Thanks.

Surely Jake’s example leaves unnecessary trailing whitespace? Also would you care about consecutive capitals, and if you did would they get treated differently?

That’s why he’s using trim I imagine. As for consecutive capitals, these are report classes - the class name is the title of the report. As they are titles I want all words upper case anyway.