Hi,
Is there a simple way of replacing a large number of substrings in a
string? I was hoping that str.replace could take a dictionary and use it
to replace the occurrences of the keys with the dict values, but that
doesnt seem to be the case.
To clarify, something along these lines..
[color=blue][color=green][color=darkred]
>>> dict_replace( "a b c", dict(a="x", b="y") )[/color][/color][/color]
"x y c"
Regards,
Will McGugan
--
Is there a simple way of replacing a large number of substrings in a
string? I was hoping that str.replace could take a dictionary and use it
to replace the occurrences of the keys with the dict values, but that
doesnt seem to be the case.
To clarify, something along these lines..
[color=blue][color=green][color=darkred]
>>> dict_replace( "a b c", dict(a="x", b="y") )[/color][/color][/color]
"x y c"
Regards,
Will McGugan
--
Comment