JS中的贪婪与懒惰
JS中正则表达式的匹配
贪婪:最长匹配
懒惰:最短匹配
懒惰只需要在贪婪的基础上加?号即可
比如说字符串 aabacbadbabe
什么都不加,默认贪婪模式
a.*b 匹配的结果是 aabacbadbab,最长范围的匹配
非贪婪模式,加?号
a.*?b匹配的结果aab,acb,adb,ab,最短的匹配
码农网 | 码农之家 | 码农人生 | 经验 | 分享 | 下载
代码积累,程序案例,经验分享,职场面试,码农人生,免费下载
JS中的贪婪与懒惰
JS中正则表达式的匹配
贪婪:最长匹配
懒惰:最短匹配
懒惰只需要在贪婪的基础上加?号即可
比如说字符串 aabacbadbabe
什么都不加,默认贪婪模式
a.*b 匹配的结果是 aabacbadbab,最长范围的匹配
非贪婪模式,加?号
a.*?b匹配的结果aab,acb,adb,ab,最短的匹配
要发表评论,您必须先登录。
Begin typing your search term above and press enter to search. Press ESC to cancel.
Thanks a lot for giving everyone an exceptionally breathtaking chance to read articles and blog posts from this site. It is often very beneficial and full of a good time for me and my office friends to visit your web site more than thrice in a week to study the fresh guides you have got. And of course, I'm so actually motivated with the impressive creative ideas you give. Some two tips on this page are certainly the most efficient we've had.