Code:
text = "('hel'lo') eq 'some 'variable he're'"
re.compile(r"(?<!\(|(?<=eq ))'(?!\)|\Z)").sub(string=text, repl="''")
Getting error:
re.error: look-behind requires fixed-width pattern
Expected output:
('hel''lo') eq 'some ''variable he''re'