Preg match on string with regex - Javascript RegExp

Javascript examples for RegExp:RegExp Match

Description

Preg match on string with regex

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
function func(i) {
    var regex = /^(?!Mozilla)/;/* www .  j  a v a  2s  .  c o  m*/
    var input = document.getElementById('input').value;
    var result = regex.test(input);
    document.getElementById('result').innerHTML = 'Result: ' + result;
}

      </script> 
   </head> 
   <body> 
      <div> 
         <input type="text" id="input" value="Mozilla"> 
         <button onclick="func()">Test</button> 
         <span id="result"></span> 
      </div>  
   </body>
</html>

Related Tutorials