如何使用JavaScript的RegExp查找除换行符以外的字符?

原创
ithorizon 5个月前 (10-19) 阅读数 54 #HTML

要查找除换行符以外的字符,请使用元字符。 (句点)。 您可以尝试运行以下代码来查找字符−

示例

<html>
   <head>
      <title>JavaScript Regular Expression</title>
   </head>
   <body>
      <script>
         var myStr = "We provide websites! We provide content!";
         var reg = /p.o/g;
         var match = myStr.match(reg);
         
         document.write(match);
      </script>
   </body>
</html>

以上就是如何使用JavaScript的RegExp查找除换行符以外的字符?的详细内容,更多请关注IT视界其它相关文章!



热门