What is a simple way to implement a find/replace algorithm on a string? I would like to transform a string using dictionary which defines replacement rules. The problem is that after each replacement, I must make sure that subsequent replacements operate on the original string. For example:
My string is: ABCABCDEFDEF
My rules are: ABC -> DEF and DEF -> XXX
So my result should be: DEFDEFXXXXXX and not XXXXXXXXXXXX (which would be the result if I were to first apply rule one and then apply rule two).