Regular Expressions 101

Community Library Entry

2

Regular Expression
PCRE (PHP <7.3)

/
(\s+[^a-z0-9]+|[^a-z0-9']+\s+|[\s&\/]|^)+(\w)
/
g

Description

Selects first letter of space separted word with exceptions. This allows bypassing 's and such.

Forcing separating charter can be set at [\s&\/]

$1: separating part $2: first letter of a word

Submitted by anonymous - 9 years ago