Regular Expressions 101

Community Patterns

Proper-case word separator

1

Regular Expression
PCRE (PHP <7.3)

/
(?<!^)((?:[A-Z](?=[a-z]))|(?:[A-Z]{2,}(?=[A-Z][a-z])))
/
gm

Description

Takes a string like 'ImageEditHRStuffSomeMOREStuff' and produces -> 'Image Edit HR Stuff Some MORE Stuff'

Submitted by Michael Keyser - 9 years ago