cmic has asked for the wisdom of the Perl Monks concerning the following question:
#!/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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: negative look behind (again)
by ww (Archbishop) on Jan 20, 2014 at 12:56 UTC | |
|
Re: negative look behind (not needed)
by Anonymous Monk on Jan 20, 2014 at 11:24 UTC | |
|
Re: negative look behind (again)
by Anonymous Monk on Jan 20, 2014 at 12:00 UTC | |
by AnomalousMonk (Archbishop) on Jan 20, 2014 at 18:52 UTC | |
|
Re: negative look behind (again)
by leslie (Pilgrim) on Jan 20, 2014 at 18:25 UTC | |
by Anonymous Monk on Jan 21, 2014 at 10:18 UTC | |
by AnomalousMonk (Archbishop) on Jan 21, 2014 at 23:44 UTC | |
|
Re: negative look behind (again)
by cmic (Acolyte) on Jan 20, 2014 at 12:22 UTC | |
by kcott (Archbishop) on Jan 20, 2014 at 14:27 UTC |