In regular expressions that is called negative look behind (also ahead, depending of the direction you need to look at). Check the tutorial on "Positive and Negative Lookahead".
You might want also check the question and answer for "Regular expression negative lookahead".
As an example, take a look at (watch\?v=.*)(?<!xx)abc
, the part (?<xx)abc
can be read as abc
matches only if the preceding letters do not match with xx
, where (?a)b
is the format to put a condition a
before apply b
. Also, the symbol <
says look behind and the exclamation mark !
is to negate the condition. I used a generic regular expression, but you can get the idea.