Regex matching over its boundaries - Javascript RegExp

Javascript examples for RegExp:RegExp Match

Description

Regex matching over its boundaries

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){//  w  w w .j a v a 2s  . c om
var testStr= "<bla bla ><body class='a b c d'><fo bar>";
var reg = /<body[^>]*>/i;
var match = reg.exec(testStr);
if(match != null){
  // we know  regex matched
  console.log(match[0].toString() + '\n');
}
    }

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials