Do a global search for numbers that are NOT "1" in a string: - Javascript RegExp

Javascript examples for RegExp:Bracket

Description

Do a global search for numbers that are NOT "1" 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() {//from   w w w  .ja  v  a2s.  com
    var str = "12121212";
    var patt1 = /[^1]/g;
    var result = str.match(patt1);
    document.getElementById("demo").innerHTML = result;
}
</script>

</body>
</html>

Related Tutorials