X
HOME HTML5 CSS3 JAVASCRIPT SQL PHP5 JQUERY ANGULAR BOOTSTRAP3 XML MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

JavaScript RegExp \r Metacharacter

RegExp Object Reference JavaScript RegExp Object

Example

Search for a carriage return character in a string:

var str = "Visit W3Schools.\rLearn Javascript.";
var patt1 = /\r/;

The marked text below shows where the expression gets a match:

Visit W3Schools.\rLearn Javascript.

Try it yourself »


Definition and Usage

The \r metacharacter is used to find a carriage return character.

\r returns the position where the carriage return character was found. If no match is found, it returns -1.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The \r metacharacter is supported in all major browsers.


Syntax

new RegExp("\\r")

or simply:

/\r/


RegExp Object Reference JavaScript RegExp Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook