代码示例:(标识:js_match_regexp_1)
<!DOCTYPE html>
<html>
<body>

<h2>JavaScript 字符串搜索</h2>

<p>在字符串中搜索 "ain":</p>

<p id="demo"></p>

<script>
let text = "The rain in SPAIN stays mainly in the plain"; 
document.getElementById("demo").innerHTML = text.match(/ain/g);
</script>

</body>
</html>
运行结果: