I have a string on which I need to do some replacements. I have a Dictionary where I have search-replace pairs defined. I have created fol
Seems reasonable to me, except for one thing: it's order-sensitive. For instance, take an input string of "$x $y" and a replacement dictionary of:
"$x" => "$y"
"$y" => "foo"
The results of the replacement are either "foo foo" or "$y foo" depending on which replacement is performed first.
You could control the ordering using a List instead. The alternative is to walk through the string making sure you don't consume the replacements in further replace operations. That's likely to be a lot harder though.