Edit This Code:
<!DOCTYPE html>
<html>
<body>

<p>The global property returns true if the "g" modifier is set, otherwise it returns false.</p>
<p>Click the button to check whether or not the "g" modifier is set.</p>

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

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

<script>
function myFunction() {
    var str = "Visit W3Schools!";
    var patt1 = /W3S/g;
    var res = patt1.global;
    document.getElementById("demo").innerHTML = res;
}
</script>

</body>
</html>


Result:
Try it Yourself - © w3schools.com
Privacy Policy