RegExp + Quantifier, matches any string that contains at least one - Javascript RegExp

Javascript examples for RegExp:Quantifier

Description

The n+ quantifier matches any string that contains at least one n.

The following code shows how to Do a global search for at least one "o":

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  ww  . j a  v  a 2s. c  om
    var str = "Hellooo World! Hello W3Schools!";
    var patt1 = /o+/g;
    var result = str.match(patt1);
    document.getElementById("demo").innerHTML = result;
}
</script>

</body>
</html>

Related Tutorials