JavaScript 参考手册
JavaScript match() 方法
在字符串中查找 "ain"
源代码:
点击运行 »
<p id="demo">单击按钮显示matches</p> <button onclick="myFunction()">点我</button> <script> function myFunction() { var str = "The rain in SPAIN stays mainly in the plain"; var n = str.match(/ain/g); document.getElementById("demo").innerHTML = n; } </script>
运行结果:
点击运行 »