Match.Value and international characters

Viewed 232

UPDATE May this post be helpful for coders using RichTextBoxes. The Match is correct for a normal string, I did not see this AND I did not see that "ä" transforms to "\e4r" in the richTextBox.Rtf! So the Match.Value is correct - human error.

A RegEx finds the correct text but Match.Value is wrong because it replaces the german "ä" with "\'e4"!

Let example_text = "Primär-ABC" and lets use the following code

String example_text = "<em>Primär-ABC</em>";
Regex em = new Regex(@"<em>[^<]*</em>" );
Match emMatch = em.Match(example_text); //Works!
Match emMatch = em.Match(richtextBox.RTF); //Fails!
while (emMatch.Success)
{
  string matchValue = emMatch.Value;
  Foo(matchValue) ...
}

then the emMatch.Value returns "Prim\'e4r-ABC" instead of "Primär-ABC".

The German ä transforms to \'e4! Because I want to work with the exact string, i would need emMatch.Value to be Primär-ABC - how do I achieve that?

1 Answers
Related