Regular expression to match numbers only in JavaScript?

JavascriptWeb DevelopmentFront End Technology

You can try to run the following code to implement regular expressions for matching only numbers −

Example

<html>
   <head>
      <title>JavaScript Regular Expressions</title>
   </head>
   <body>
      <script>
         var myStr = "5200% Demo";
         var reg = /\d/g;

         var match = myStr.match(reg);

         document.write(match);
      </script>
   </body>
</html>
raja
Published on 16-Feb-2018 12:40:22
Advertisements