Javascript examples for RegExp:Metacharacter
The \r metacharacter matches a carriage return character.
If no match is found, it returns -1.
The following code shows how to Search for a carriage return character in a string:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {//w ww. j av a2 s. c o m var str = "Visit java2s.com.\rLearn JavaScript."; var patt1 = /\r/; var result = str.search(patt1); document.getElementById("demo").innerHTML = result; } </script> </body> </html>