in reply to negative look ahead
my $string = qq*<sec>here the text goes <pg> and text continues*; my ($match) = $string =~ /(<sec>.*)(?=<pg>)/; [download]