<html>
<body>
<p>单击该按钮可执行全局 (/g) 搜索字符串中的字母“ain”(/ain),并显示匹配项。</p>
<button onclick="myFunction()">试一试</button>
<p id="demo"></p>
<script>
function myFunction() {
var str = "The rain in SPAIN stays mainly in the plain";
var res = str.match(/ain/g);
document.getElementById("demo").innerHTML = res;
}
</script>
</body>
</html>