Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8292921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:38:58+00:00 2026-06-08T13:38:58+00:00

UPDATE May this post be helpful for coders using RichTextBoxes. The Match is correct

  • 0

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 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T13:39:00+00:00Added an answer on June 8, 2026 at 1:39 pm

    In what context are you doing this?

    string example_text = "<em>Ich bin ein Bärliner</em>";
    Regex em = new Regex(@"<em>[^<]*</em>" );
    Match emMatch = em.Match(example_text);
    while (emMatch.Success)
    {
        Console.WriteLine(emMatch.Value);
        emMatch = emMatch.NextMatch();
    }
    

    This outputs <em>Ich bin ein Bärliner</em> in my console

    The problem probably isn’t that you’re getting the wrong value back, it’s that you’re getting a representation of the value that isn’t displayed correctly. This can depend on a lot of things. Try writing the value to a text file using UTF8 encoding and see if it still is incorrect.

    Edit: Right. The thing is that you are getting the text from a WinForms RichTextBox using the Rtf property. This will not return the text as is, but will return the RTF representation of the text. RTF is not plain text, it’s a markup format to display rich text. If you open an RTF document in e.g. Notepad you will see that it has a lot of weird codes in it – including \'e4 for every ‘ä’ in your RTF document. If you would’ve used some markup (like bold text, color etc) in the RTF box, the .Rtf property would return that code as well, looking something like {\rtlch\fcs1 \af31507 \ltrch\fcs0 \cf6\insrsid15946317\charrsid15946317 test}

    So use the .Text property instead. It will return the actual plain text.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

UPDATE: Perhaps this wasn't clear from my original post, but I'm mainly interested in
(Related to this post , but not the same.) Is there any way to
UPDATE!! I am sorry for this post, the code I had written for this
I have a similar challenge to this post: Batch insert/update with entity framework from
I'm playing around with some image filters using Canvas after reading this post this
Common situation: I have a client on my server who may update some of
Update: I reported this as a bug to Apple and they fixed it! All
UPDATE: I've been playing around with this more, and it seems like tmux's clear-history
Update : This is no longer an issue from C# 6, which has introduced
UPDATE As Mathias notes below, this exact problem has been reported and resolved here:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.