This fails because your lookbehind isn't anchored. You can either anchor it where you want or if it's really always at the start, replace the lookbehind with a lookahead like so:
while (<DATA>) { if (/^(?!TAGS)(.*?)(?=TAG2)/xgi ) { print "Negative lookahead: "; print $1, "\n"; } } # __DATA__ TAG1 text one TAG2 TAG1 text two TAG2 TAG1 text three TAG2 TAGS text four TAG2 TAG1 text five TAGT TAG1 text six TAG2
In reply to Re: lookbehind regexp
by hippo
in thread lookbehind regexp
by cmic
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |