Regular Expressions 101

Community Patterns

Group first letter, Group Remaining letters, Group White space

1

Regular Expression
PCRE (PHP <7.3)

/
(\s+)((?<=\s)[a-z]|^[a-z]).*?([A-Z]?(?<=[a-zA-Z0-9])[a-zA-Z0-9]+)
/
g

Description

first groups all white space $1 second groups all first letter of every word except capitals third groups remaining letters

Submitted by slimelord - a year ago