<html>
<body>
<h2>JavaScript Regular Expressions</h2>
<p>The exec() method tests for a match in a string:</p>
<p id="demo"></p>
<script>
let text = "Hello world!";
// look for "Hello"
let result1 = /Hello/.exec(text);
// look for "W3Schools"
let result2 = /W3Schools/.exec(text);
document.getElementById("demo").innerHTML =
result1 + "<br>" + result2;
</script>
</body>
</html>