PHP前端开发

找到任何替代文本的JavaScript RegExp是什么?

百变鹏仔 4周前 (09-22) #HTML
文章标签 文本

匹配任何指定的替代方案,请按照下面给出的模式−

(foo|bar|baz)

示例

您可以尝试运行以下代码来查找任何替代文本 −

<html>   <head>      <title>JavaScript Regular Expression</title>   </head>   <body>      <script>         var myStr = "one,one,one, two, three, four, four";         var reg = /(one|two|three)/g;         var match = myStr.match(reg);         document.write(match);      </script>   </body></html>