Basic search with regex in javascript - Javascript RegExp

Javascript examples for RegExp:RegExp test

Description

Basic search with regex in javascript

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript" src="https://code.jquery.com/jquery-1.8.3.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){/*from  www.  j  a  va 2 s .  c  om*/
var input = 'test test one two three  one  three one two three two ';
var match = [];
if (input.match(/^(?=.*\bone\b)(?=.*\btwo\b)(?=.*\bthree\b)/i)) {
  match = input.match(/\b(one|two|three)\b/ig);
}
console.log(match);
    });

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

Related Tutorials