I have the folowing expression:
a = 'x11 + x111 + x1111 + x1'
and I would like to replace the following:
from_ = ['1', '11', '111', '1111']
to = ['2', '22', '333', '3333']
and therefore obtain the following result:
anew = 'x22 + x333 + x3333 + x2'
How can I do this using Python?
This is a similar question to: Python replace multiple strings. However in my case the replaced values are being overwiten by themselves if I use the suggested anwsers in the question. Hence, in the metioned link the result is 'x22 + x222 + x2222 + x2'