I want to replace a regex with '*', but only if the regex is out side of <>. The whole point is to not interfere with the html tags.
I use this to replace:
re.sub(r'SOMEREGEX(?=[^>]*(<|$))', '*', line)
However I ran into his problem: if my regex is:
f.*k
Then this:
fzzzzzzzzz<HTMLTAG>zzzzzzzk
Would become an '*', which I don't want. How do I overcome this problem?
Constraints:
-All brackets are matched
-No nested brackets
-SOMEREGEX is provided by the user. I prefer not changing that.