#!/usr/local/bin/perl #use strict; use warnings; #use re debug; while (<DATA>) { # This section works OK. # if (/(?<=TAG1)(.*)(?=TAG2).*?/x) { # print $1, "\n"; # } if (/^(?<!TAGS)(.*?)(?=TAG2).*$/x ) { print $1, "\n"; } } __DATA__ TAG1 text one TAG2 etc TAG1 text two TAG2 etc TAG1 text three TAG2 etc TAGS text four TAG2 etc TAG1 text five TAGT etc
In reply to negative look behind (again) by cmic
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |