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

  • Home
  • SEARCH
  • 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 45323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T15:47:27+00:00 2026-05-10T15:47:27+00:00

I have a regex call that I need help with. I haven’t posted my

  • 0

I have a regex call that I need help with.

I haven’t posted my regex, because it is not relevant here. What I want to be able to do is, during the Replace, I also want to modify the ${test} portion by doing a Html.Encode on the entire text that is effecting the regex.

Basically, wrap the entire text that is within the range of the regex with the bold tag, but also Html.Encode the text inbetween the bold tag.

RegexOptions regexOptions = RegexOptions.Compiled | RegexOptions.IgnoreCase; text = Regex.Replace(text, regexBold, @'<b>${text}</b>', regexOptions); 
  • 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. 2026-05-10T15:47:28+00:00Added an answer on May 10, 2026 at 3:47 pm

    Heres an implementation of this I’ve used to pick out special replace strings from content and localize them.

            protected string FindAndTranslateIn(string content)         {             return Regex.Replace(content, @'\{\^(.+?);(.+?)?}', new MatchEvaluator(TranslateHandler), RegexOptions.IgnoreCase);         }  public string TranslateHandler(Match m) {     if (m.Success)     {         string key = m.Groups[1].Value;         key = FindAndTranslateIn(key);         string def = string.Empty;         if (m.Groups.Count > 2)         {             def = m.Groups[2].Value;             if(def.Length > 1)             {                 def = FindAndTranslateIn(def);             }         }          if (group == null)         {             return Translate(key, def);         }         else         {             return Translate(key, group, def);         }     }     return string.Empty; } 

    From the match evaluator delegate you return everything you want replaced, so where I have returns you would have bold tags and an encode call, mine also supports recursion, so a little over complicated for your needs, but you can just pare down the example for your needs.

    This is equivalent to doing an iteration over the collection of matches and doing parts of the replace methods job. It just saves you some code, and you get to use a fancy shmancy delegate.

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

Sidebar

Ask A Question

Stats

  • Questions 73k
  • Answers 73k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer I'd recommend abandoning C3P0 and using the JNDI naming service… May 11, 2026 at 1:56 pm
  • added an answer I don't believe so. If you really had to have… May 11, 2026 at 1:56 pm
  • added an answer Here's a Python port of Easiest way to convert a… May 11, 2026 at 1:56 pm

Related Questions

I have a regex call that I need help with. I haven't posted my
I have a regex that is going to end up being a bit long
I have a RegEx that is working for me but I don't know WHY
I have a regex created from a list in a database to match names
i have a list of regex patterns (stored in a list type) that I
For a poor man's implementation of near -collation-correct sorting on the client side I
I have a big string (let's call it a CSV file, though it isn't
Let me start with a specific example of what I'm trying to do. I
In Python, is there a better way to parameterise strings into regular expressions than

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.