Regular Expressions For New Line

Category: Strings | Views Total: 186 views

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.

/[\r\n]+/

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

/(\r\n|\r|\n)/

Rate This Regex
Sending
User Review
0 (0 votes)

Leave a Reply