Javascript examples for RegExp:Metacharacter
The \d metacharacter matches a digit from 0-9.
The following code shows how to Do a global search for digits:
<!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>