#!/usr/bin/perl # https://perlmonks.org/?node_id=11101201 use strict; use warnings; # # Negative lookbehind , huh ?? # while () { if (/^(?!TAGS)(.*?)(?=TAG2)/xgi ) { print "Non-Negative lookbehind: "; 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