代码示例:(标识:js_match_regexp_2)
<!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/gi);
</script>

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