JavaScript RegExp \n metacharacter
JavaScript RegExp Object
Definition and Usage
The \n metacharacter is used to find newline characters.
\n returns the position where the newline was found. If no match is found, it returns -1.
Syntax
new RegExp("\n")
Or a simpler way:
/\n/
Browser support





All major browsers support the \n metacharacter
Example
Example
Search for newline characters in the string:
var str="Visit RUNOOB.\nLearn Javascript.";
var patt1=/\n/;
The text marked below shows where the expression found matches:
Visit RUNOOB.
\n
Learn Javascript.
Try it »
JavaScript RegExp Object