Regular Expressions 101

Community Patterns

Remove single, but not repeating newlines, except immediately after a period. (xiTWA2/1)

1

Regular Expression
PCRE (PHP <7.3)

/
(?<![\.\n]) ?\n(?!\n)
/
gsm

Description

Intended as a first pass on already word wrapped text, to remove wrap newlines while preserving likely intentional ones.

Not especially robust.

Submitted by Tristan - 3 years ago