RegExp ?! Quantifier, matches any string that is not followed by a specific string n. - Javascript RegExp

Javascript examples for RegExp:Quantifier

Description

The ?!n quantifier matches any string that is not followed by a specific string n.

The following code shows how to Do a global, case insensitive search for "is" not followed by " all":

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

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

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

<script>
function myFunction() {//ww  w . ja v  a2  s  . c o  m
    var str = "Is this all there is";
    var patt1 = /is(?! all)/gi;
    var result = str.match(patt1);
    document.getElementById("demo").innerHTML = result;
}
</script>

</body>
</html>

Related Tutorials