Find a new line character with JavaScript RegExp.

HTMLJavascriptProgramming Scripts

To find a new line character with JavaScript Regular Expression, use the following −

\n

Example

You can try to run the following code to find a new line character. It returns the position where the new line (\n) is found −

<html>
   <head>
      <title>JavaScript Regular Expression</title>
   </head>
   <body>
      <script>
         var myStr = "UI \n Responsive!";
         var reg = /\n/;
         var match = myStr.search(reg);

         document.write(match);
      </script>
   </body>
</html>
raja
Published on 26-Feb-2018 11:16:30
Advertisements