Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
PCRE (PHP <7.3)

/
([^\n])\n(?=[^\n])
/
gm

Description

In the first capturing group, match any character that isn't a newline, then, match a newline, then, in a non-capturing group, match a newline. Replace the the entire matched sequence with contents of the first capturing group followed by a space.

Submitted by anonymous - 2 years ago