How to perform Multiline matching with JavaScript RegExp?

HTMLJavascriptProgramming Scripts

To perform multiline matching, use the M modifier available in JavaScript Regular Expression.

Example

You can try to run the following code to perform multiline matching −

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

   <body>
      <script>
         var myStr = "Welcom\ning!";
         var reg = /^ing/m;
         var match = myStr.match(reg);
         
         document.write(match);
      </script>
   </body>
</html>
raja
Published on 26-Feb-2018 10:52:36
Advertisements