Find word character in a string with JavaScript RegExp?

HTMLJavascriptProgramming Scripts

To find a word character (a-z, A-Z, 0-9, _) in a string with JavaScript Regular Expression, use the following −

\w

Example

You can try to run the following code to find word character in a string −

<html>
   <head>
      <title>JavaScript Regular Expression</title>
   </head>
   <body>
      <script>
         var myStr = "100% Responsive!";
         var reg = /\w/g;
         var match = myStr.match(reg);
         document.write(match);
      </script>
   </body>
</html>
raja
Published on 23-Feb-2018 17:44:00
Advertisements