Home  >  Article  >  Web Front-end  >  Find non-space characters using JavaScript regular expression

Find non-space characters using JavaScript regular expression

WBOY
WBOYforward
2023-08-20 08:34:051094browse

Find non-space characters using JavaScript regular expression

To find non-whitespace characters, use the following code −

\S

Example

You can try to run the following code to find non-whitespace character −

<html>
   <head>
   <title>JavaScript Regular Expression</title>
   </head>
   <body>
      <script>
         var myStr = "100% Responsive!";
         var reg = /\S/g;
         var match = myStr.match(reg);
         
         document.write(match);
      </script>
   </body>
</html>

The above is the detailed content of Find non-space characters using JavaScript regular expression. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete