Why? Because negative lookbehind is satisfied at any position except immediately after the given subpattern. Thus your (.*?) is free to match at the very beginning. Using a lookahead may accomplish what you had in mind (if $1 must contain the start tag).
if (/^(?!TAGS)(.*?)TAG2/x ) { ...
In reply to Re: negative look behind (again)
by Anonymous Monk
in thread negative look behind (again)
by cmic
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |