I was looking for a format in Python's module re.sub() that achieves below if possible.
string = "All cats are kings, but not all kings are cats."
a, b = ["cats", "CATS"]
c, d = ["kings", "KINGS"]
x = string.replace(a, b).replace(c, d)
print(x)
Output:
All CATS are KINGS, but not all KINGS are CATS.
I wanted to find out if I could substitute pattern1 with repl1, and pattern2 with repl2 with a syntax that similar to below:
import re
x = re.sub("pattern1|pattern2", "repl1|repl2", string)
Is this even possible?