<!DOCTYPE html>
<html>
<body>

<p>Click the button to do a global, multiline search for "is" at the beginning of each line in a string.</p>

<button onclick="myFunction()">Try it</button>

<p id="demo"></p>

<script>
function myFunction() {
    var str = "\nIs th\nis h\nis?";
    var patt1 = /^is/gm;
    var result = str.match(patt1);
    document.getElementById("demo").innerHTML = result;
}
</script>

</body>
</html>