RegExp \d Metacharacter - Javascript RegExp

Javascript examples for RegExp:Metacharacter

Description

The \d metacharacter matches a digit from 0-9.

The following code shows how to Do a global search for 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() {// w ww.ja va 2  s . c o m
    var str = "this is  100%!";
    var patt1 = /\d/g;
    var result = str.match(patt1);
    document.getElementById("demo").innerHTML = result;
}
</script>

</body>
</html>

Related Tutorials