简单教程
提交运行
代码编辑器:
<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>
运行结果: