Tryit Editor v2.3

Edit This Code:
<!DOCTYPE html> <html> <body> <p>Do a global search, and test for "Hello" and "W3Schools" in a string:</p> <button onclick="myFunction()">Try it</button> <p id="demo"></p> <script> function myFunction() { var str = "Hello world!"; //look for "Hello" var patt = /Hello/g; var result = patt.test(str); //look for "W3Schools" patt2 = /W3Schools/g; result2 = patt2.test(str); document.getElementById("demo").innerHTML = result + "<br>" + result2; } </script> </body> <!-- Mirrored from www.w3schools.com/jsref/tryit.asp?filename=tryjsref_regexp_test by HTTrack Website Copier/3.x [XR&CO'2014], Fri, 23 Jan 2015 08:27:42 GMT --> </html>
Result:
Try it Yourself - © w3schools.com