JS中的贪婪与懒惰

JS中的贪婪与懒惰
JS中正则表达式的匹配
贪婪:最长匹配
懒惰:最短匹配

懒惰只需要在贪婪的基础上加?号即可

比如说字符串 aabacbadbabe
什么都不加,默认贪婪模式
a.*b 匹配的结果是 aabacbadbab,最长范围的匹配
非贪婪模式,加?号
a.*?b匹配的结果aab,acb,adb,ab,最短的匹配

Pls call me CPP.
Posts created 150

One thought on “JS中的贪婪与懒惰

  1. 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.

发表评论

Related Posts

Begin typing your search term above and press enter to search. Press ESC to cancel.

Back To Top