RegExp {X} Quantifier, matches any string that contains a sequence of X n's. X must be a number. - Javascript RegExp

Javascript examples for RegExp:Quantifier

Description

The n{X} quantifier matches any string that contains a sequence of X n's. X must be a number.

The following code shows how to Do a global search for a substring that contains a sequence of four digits:

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  ww w . jav a2  s.  c  om
    var str = "100, 1000 or 10000? asdf 1234";
    var patt1 = /\d{3,4}/g;
    var result = str.match(patt1);
    document.getElementById("demo").innerHTML = result;
}
</script>

</body>
</html>

Related Tutorials