Regular Expressions 101

Community Patterns

Remove Widows (PHP)

7

Regular Expression
PCRE (PHP <7.3)

/
\s(([a-zA-Z]+\-[a-zA-Z]+|[a-zA-Z]+)\.)
/
g

Description

Adds a non-breaking space between the last two words of sentences

Submitted by herkulano - 9 years ago