Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
PCRE (PHP <7.3)

/
([A-Z][a-z]+|[A-Z]+(?![a-z])|[0-9]+)
/
g

Description

Splits CamelCase single string into separate strings. Can be used for transforming CamelCase to snake_case.

Also works with numbers and capital letter shortcuts (e.g SomeWTFVariable1).

Submitted by Nicolas - 9 years ago