I'm trying to replace a string with regex via Match
Evaluator delegate. [dictionary method] when the string starts with: .- &*?
. I get a error with the following details:
the given key was not present in the dictionary.
What can I do?
IDictionary<string, string> dict = new Dictionary<string, string> ()
{
{ "-", "e" },
{ "?", "z'" },
};
string str1 = "-50"
var p = new Regex(String.Join("|", dict.Keys));
str2 = p.Replace(str1, x => dict[x.Value]);