Find digit with JavaScript RegExp.

HTMLJavascriptProgramming Scripts

To find a digit (0-9) with JavaScript Regular Expression, use the following −

\d

Example

You can try to run the following code to find a digit −

<html>
   <head>
      <title>JavaScript Regular Expression</title>
   </head>
   <body>
      <script>
         var myStr = "100% Responsive!";
         var reg = /\d/g;

         var match = myStr.match(reg);

         document.write(match);
      </script>
   </body>
</html>
raja
Published on 26-Feb-2018 06:35:20
Advertisements