参考菜鸟教程中的一个例子:
source code:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>菜鸟教程(runoob.com)</title>
</head>
<body>
<script>
var str = "Is is the cost of of gasoline going up up";
var patt1 = /\b([a-z]+) \1\b/ig;
document.write(str.match(patt1));
</script>
</body>
</html>
output:
Is is,of of,up up
分析:
捕获的表达式,即()内部的内容。正如