Note that (?:stuff) is a non-grouping set of parens, and (?!stuff) is a negative assertion./foo((?:(?!bar).)*)foo/
UPDATE
I noticed a while ago that my RE was incorrect, decided to leave it for someone else to find and mention. But nobody did so I will mention that I forgot a ?:
/foo((?:(?!bar).)*?)foo/
In reply to RE (tilly) 2: Regex'ing backreferences
by tilly
in thread Regex'ing backreferences
by Uruk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |