Home  >  Article  >  Web Front-end  >  Search for carriage return symbols using regular expressions in JavaScript

Search for carriage return symbols using regular expressions in JavaScript

PHPz
PHPzforward
2023-09-16 09:33:03882browse

Search for carriage return symbols using regular expressions in JavaScript

To find carriage returns using JavaScript regular expressions, use the following code -

\r

Example

You can try running the following code to find the carriage return character. It returns the position where the carriage return (\r) character is found -

<html>
   <head>
      <title>JavaScript Regular Expression</title>
   </head>

   <body>
      <script>
         var myStr = "100% \r Responsive!";
         var reg = /\r/;
         var match = myStr.search(reg);
         
         document.write(match);
      </script>
   </body>
</html>

The above is the detailed content of Search for carriage return symbols using regular expressions in JavaScript. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete
Previous article:MathML example in HTML5Next article:MathML example in HTML5