in reply to How can I build regexp with "not" assertion?

I think what you need is:
$line =~ s/(pattern1)((?!pattern1).)+pattern2.+?\1/substitute/gs;
It worked well on Perl v5.8.8

Replies are listed 'Best First'.
Re^2: How can I build regexp with "not" assertion?
by putnik (Novice) on Feb 22, 2008 at 14:15 UTC
    Thank you, your solution work too :) I didn't check it tightly, but it's look suitable.