In both cases, the regexp succeed. In the first case, b+ picks up all four b's. In the second case, b* picks up zero b's. Why is + greedy in this example, but * is not? I try to find enlightment at perlre, but with no success.$ perl -lwe '"abbbbc"=~/(b+)/ && print "Found: $1"' Found: bbbb $ perl -lwe '"abbbbc"=~/(b*)/ && print "Found: $1"' Found:
In reply to Greediness of * vs. greediness of + by rovf
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |