Regular Expressions 101

Community Patterns

Replace all newlines (except double newlines) with spaces


Regular Expression
PCRE (PHP <7.3)



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