<body>
<script>
var str="Is this all there is";
var patt1=/(.*is)(?= all)/
document.write(str.match(patt1))
</script>
</body>
结果如下,很是疑惑

本文解析了JavaScript中的正则表达式,通过实例`varstr=Isthisallthereis; var patt1=/(.*is)(?=all)/`展示了如何使用`patt1`匹配字符串。重点在于演示了查找以'is'开头且紧接'all'的子串技巧。
<body>
<script>
var str="Is this all there is";
var patt1=/(.*is)(?= all)/
document.write(str.match(patt1))
</script>
</body>
结果如下,很是疑惑


被折叠的 条评论
为什么被折叠?