Search for a carriage return character in a string:
var patt1 = /\r/;
The marked text below shows where the expression gets a match:
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.
The \r metacharacter is supported in all major browsers.
Thank You For Helping Us!
Your message has been sent to W3Schools.