Computer >> Computer tutorials >  >> Programming >> Javascript

Find digit with JavaScript RegExp.


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>