Greedy means the longest valid match. aaa isn't valid (because followed by b) so the longest match is aa (which is a series of 'a's not followed by b, exactly what you asked for). Adding a + to a quantifier, making it possessive, will prevent partial backtracking though (meaning if a given subpattern can match a longer string, it is the only string that it can accept). So /^a{2,}+(?!b)/ will work as expected. /^a{2,}(?![ab])/ is another solution.
In reply to Re: Greedy match and zero-width negative lookahead assertion
by Eily
in thread Greedy match and zero-width negative lookahead assertion
by jeffatrobertsdotnet
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |