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 6846375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:36:50+00:00 2026-05-27T00:36:50+00:00

Im trying to highlight words, letters or anything marked in a Regular Expression. Im

  • 0

Im trying to highlight words, letters or anything marked in a Regular Expression.
Im using RichTextBox in Silverlight (take care that Silverlight has NOT uses the same .NET Framework than others apps, for example it HAS NOT the TextRange)

Everytime the text has a \r\n or \n\r the pointers moves 4 position forward. But the really bad is when i do the highlight, the style text add 4 positions more. Even, i think he has more erratic behavior than racional. Please advice me something in this!

Thanks FailDev.

The text im using for try this is:

ffffffffffafffffffffff
fffffafffffffffff
fffffffffffffafffffffff

(4 lines, after the last f there is a carrier return \ line feed)

Also this one doesnt work with my code (has the erratic behavior, or not):

ffffffffffaaffffffafffff
fffffafffffffffff
fffffffffffffafffffffff

(4 lines, after the last f there is a carrier return \line feed)

The idea is highlight with blue, bold and underline the “a” character.

The last code that i tried is this:

MatchCollection CarrierReturns =  MainGeneral.Build_Regex(@"[\r\n|\n\r]", false);

            MatchCollection WordsFound =  MainGeneral.Build_Regex("[a]", false);
            foreach (Match x in WordsFound) {
                int StringCarrierCount = 0;

                if (CarrierReturns.Count > 0)
                {
                    foreach (Match CR in CarrierReturns)
                    {
                        if (x.Index > CR.Index)
                        {
                            textBox1.Text += " CI:" + StringCarrierCount + "- ";
                            break;
                        }
                        StringCarrierCount++;
                    }
                }

                if (x.Index < CarrierReturns[0].Index) { StringCarrierCount = 0; }

                StringBegin = 2 + x.Index + (4 * StringColorCounter) + (4 *  StringCarrierCount);
                StringEnd = StringBegin + x.Length;
                textBox1.Text += StringBegin + "-" + StringEnd + " ";
                StringColorCounter++;

                StartPoint = MainData.ContentStart.GetPositionAtOffset(StringBegin, LogicalDirection.Forward);
                EndPoint = MainData.ContentStart.GetPositionAtOffset(StringEnd, LogicalDirection.Forward);
                MainData.Selection.Select(StartPoint, EndPoint);
                MainData.Selection.ApplyPropertyValue(TextElement.ForegroundProperty, new SolidColorBrush(Colors.Blue));
                MainData.Selection.ApplyPropertyValue(Run.TextDecorationsProperty, TextDecorations.Underline);
                MainData.Selection.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Bold);
            }

Thanks in advance, please ask me before rate bad! 🙂

  • 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-05-27T00:36:51+00:00Added an answer on May 27, 2026 at 12:36 am

    A line separator may be any of \r\n (carriage-return + linefeed), \n (linefeed alone), or \r (carriage-return alone). The correct way to match one would be with \r\n|[\r\n].

    Your regex – [\r\n|\n\r] – matches exactly one character; any of \r, \n, or |. That means, whenever the line separator is \r\n, your code acts like there are two line separators, not one.

    There may be other errors in your code as well, but I don’t really understand what it’s trying to do. I’m sure the regex is incorrect.

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

Sidebar

Related Questions

I am trying to highlight the word that has been passed in using regex
I'm trying to highlight just one specific row in a table using jQuery. The
I'm trying to write a Google chrome extension so that I can highlight text
I'm trying to highlight a field when the value has the word 'deadline' in
I'm trying to highlight the text that matches the query in a live search
I am implementing a website search and am trying to highlight the words the
In the below script I am trying to highlight all the words in a
I'm trying to highlight a text in the html string by using Html Agility
i am trying to make my WebBrowser control highlight some words. i found this
I am trying to edit the jQuery hightlight plug in to highlight multiple words.

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.