text = "abcde"
var = "X"
text = re.sub("b(c)d", var, text)
Actual output: aXe
Wanted output: abXde
It's replacing the whole pattern, I only want it to replace group 1 of the pattern. How do I make regex do this?
text = "abcde"
var = "X"
text = re.sub("b(c)d", var, text)
Actual output: aXe
Wanted output: abXde
It's replacing the whole pattern, I only want it to replace group 1 of the pattern. How do I make regex do this?