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

Given your example, if you are trying to do substitutions on all the lines which match all the 2-numbered lines, just ignore the "not parts" ...

$line =~ s/(pattern1).+?pattern2.+?\1/substitute/;

... Above will work since "pattern2" does not appear (per your example) in any lines identified by the 1s, so they remain unchanged.

Replies are listed 'Best First'.
Re^2: How can I build regexp with "not" assertion?
by putnik (Novice) on Feb 17, 2008 at 17:36 UTC
    Thank you, but sorry, it work in wrong way. I tried this, but got
    1stline....subst... 1a line....subst.....
    I mean it substituted all in parenthesis this way:
    1stline....(pattern1.......pattern1..... 2ndline....pattern1.....pattern2...pattern1)...
    I CAN'T split it in lines, i must treat all dada as a single line because \n may appear in any place