Split camelCase word into words with php preg_match (Regular Expression)

You can use preg_split as:

$arr = preg_split('/(?=[A-Z])/',$str);

See it

I’m basically splitting the input string just before the uppercase letter. The regex used (?=[A-Z]) matches the point just before a uppercase letter.

Leave a Comment