Regular Expressions For New Line

Category: Strings

A regular expression to match a new line (linebreaks).

Note that Linux uses \n for a new-line, Windows \r\n, and old Macs \r.


The regex above also matches multiple consecutive new lines. Use the following regex to fix that:


See Also:

Rate This Regex
User Review
0 (0 votes)

Expression Flags

Flags Description
i Ignore case sensitive.
g Allows global search.
m Allows multiline search.