Do a global, multiline search for "is" at the beginning of each line in a string: - Javascript RegExp

Javascript examples for RegExp:Bracket

Description

Do a global, multiline search for "is" at the beginning of each line in a string:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction()">Test</button>

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

<script>
function myFunction() {/*  w w w.j  av a 2  s  .c  om*/
    var str = "\nIs th\nis h\nis?";
    var patt1 = /^is/gm;
    var result = str.match(patt1);
    document.getElementById("demo").innerHTML = result;
}
</script>

</body>
</html>

Related Tutorials