Hi,
>
What is the regex to replace & # 1 0 6 ; to character? Any Ideas?
Thanks,
Mo
You can't "replace" with regex, only "find" (which can then be used to "replace").
Try this to replace all &#<number>; codes with the correct character:
private static string DecodeMatch(Match m)
{
string s = m.ToString(); // "&#" 0-9 ";"
string s2 = s.Substring(2, s.Length-3);
int i = Int32.Parse(s2);
Char c = Convert.ToChar(i);
return c.ToString();
}
public string Decode(string s)
{
string result = Regex.Replace(s, @"&#[0-9]+;",
new MatchEvaluator(Formatter.DeencodeMatch));
return result;
}
Hans Kesting