<!DOCTYPE html>
<html>
<body>

<p>Click the button to do a global search for the number "1" in a string.</p>

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

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

<script>
function myFunction() {
    var str = "12121212";
    var patt1 = /[1]/g;
    var result = str.match(patt1);
    document.getElementById("demo").innerHTML = result;
}
</script>

</body>
</html>