RegExp \ n metacharacter
Definition and Usage
\ N metacharacter used to find line breaks.
\ N newline return position is found. If no match is found, it returns -1.
grammar
new RegExp("\n")
或者更简单方式:
/\n/
或者更简单方式:
/\n/
Browser Support
All major browsers support \ n metacharacter
Examples
Examples
Search string newline character:
var str="Visit W3Cschool.\nLearn Javascript.";
var patt1=/\n/;
var patt1=/\n/;
The marked text below shows where the expression gets a match:
Visit W3Cschool. \n Learn Javascript.
try it"
JavaScript RegExp Object