(Side :) note also that the regex expression (?![b])+ is problematic in the quoted match because it asks the regex engine to match a zero width assertion as many times as possible. Perl would have warned you about this if you had asked it to by enabling warnings:
c:\@Work\Perl\monks>perl -wMstrict -le "$_ = 'aaab'; print qq{Matched 1 => '$_'} if /^[a]{2,}(?![b])+/; print qq{LastMatch1: '$&'}; " (?![b])+ matches null string many times in regex; marked by <-- HERE in m/^[a]{2,}(?![b])+ <-- HERE / at -e line 1. Matched 1 => 'aaab' LastMatch1: 'aa'
Update: "Possessive" quantifiers were added with Perl version 5.10. Prior to that version and to date, the same functionality can be had with the independent or "atomic" subexpression (?>pattern)
Give a man a fish: <%-{-{-{-<
In reply to Re: Greedy match and zero-width negative lookahead assertion
by AnomalousMonk
in thread Greedy match and zero-width negative lookahead assertion
by jeffatrobertsdotnet
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |