I can't figure out reverse negative lookup. Suppose I have a text
qwe abc
qwe abc
abc
and I want to find all abc
which is not going after qwe
, which might be followed by any amount of spaces.
(?<!qwe)\s*?(abc)
Matches everything. I assumed it would be something like "match arbitrary amount of spaces followed by abc
if there's no qwe
in front of it"
I tried also
qwe|(abs)
approach, but it does not work for me. Although groups are empty for the cases where I do not want match to work, I don't really get how do I use it with re.sub
function (which need to). Even though groups are empty, re.sub
does replace the string.
Env: python 3