首頁  >  文章  >  web前端  >  使用JavaScript正規表示式尋找非空格字符

使用JavaScript正規表示式尋找非空格字符

WBOY
WBOY轉載
2023-08-20 08:34:051095瀏覽

使用JavaScript正規表示式尋找非空格字符

要尋找非空白字符,請使用以下程式碼−

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

以上是使用JavaScript正規表示式尋找非空格字符的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:tutorialspoint.com。如有侵權,請聯絡admin@php.cn刪除