(?!bar) is a negative lookahead assertion. It is zero width assertion, so it anchors the match but doesn't use any characters. (?!bar). matches a character which is not the start of a bar sequence.
So, with that in mind: ((?!bar).){1,5} matches as many characters as it can (up to 5, and at least 1) that is not the start of the character sequence bar.
In reply to Re: Why isn't this regex greedy?
by GrandFather
in thread Why isn't this regex greedy?
by Melly
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |