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

Find the non-digit character with JavaScript Regular Expression.


To find non-digit characters with JavaScript Regular Expression, use the following:

\D

Example

You can try to run the following code to find non-digit characters:

<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>