懒惰匹配模式即表示以最少的匹配量返回匹配个数,默认是非懒惰匹配模式
表达式
<script>
var str = "{aaa}a{bbb}";
var patt1 = /(\{(.*?)\})/g;
console.log(str.match(patt1));
</script>
匹配结果:
[
"{aaa}",
"{bbb}"
]
懒惰匹配模式即表示以最少的匹配量返回匹配个数,默认是非懒惰匹配模式
表达式
<script>
var str = "{aaa}a{bbb}";
var patt1 = /(\{(.*?)\})/g;
console.log(str.match(patt1));
</script>
匹配结果:
[
"{aaa}",
"{bbb}"
]
本文标题:正则表达式懒惰型元字符匹配 ?
本文链接:https://www.haomeiwen.com/subject/vegxcxtx.html
网友评论