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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:57:50+00:00 2026-05-13T17:57:50+00:00

I am bit new to c#, i am looking for a string matching pattern

  • 0

I am bit new to c#, i am looking for a string matching pattern to do the following,

I have a string like this

The book will be showcased at a
reception in Number 11 Downing Street
and will be attended by key healthcare

i need to create a span tag to highlight some text fragments using startIndex and length,

for an example,

  1. startIndex = 3, Length = 10
  2. startIndex = 8, Length = 8

i need to create a span tag dynamically and also create a separate span tag for intersections

in this case,

The < span id= 'span1' color='blue'> book < /span> < span id='intersectionSpan' color= pink > will </ span> < span id '= span2' color = 'yellow' > be showcased </ span>

anyone has come across any kinds of design pattern or smiler problems

please advice

  • 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-13T17:57:50+00:00Added an answer on May 13, 2026 at 5:57 pm

    I don’t think this related to desing pattern but i would look to what u asked as custom control

    as you know the label control will render as a span so start to make new control customlabel for example inherit it from the label control and creta functions inside it to accept the locations (startindex and length ) and the color (red , yellow )

    let’s say we have this function inside the control

     private string AddSpan(string originalString, int[] location, string color)
        {
            string old = originalString.Substring(location[0], location[1]);
            string newStr = string.Format("<span id= '{0}' color='{1}'>", "idUWant", color);
            originalString = originalString.Replace(old, newStr);
            return originalString ; 
        }
    

    the originaltext is The book will be showcased at a reception in Number 11 Downing Street
    and will be attended by key healthcare

    the location is simple 2 dimension array of integer the first one will be the start index and second one will be length , color parameter is color string

    i think it’s better to make data container for the paramters like a class holiding only a few properties like startindex and length and color to make it easier for reading and maintaining

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

Sidebar

Ask A Question

Stats

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

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

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer While I didn't see it in your question, I presume… May 17, 2026 at 1:53 am
  • Editorial Team
    Editorial Team added an answer There's probably a better way to go about this, for… May 17, 2026 at 1:53 am
  • Editorial Team
    Editorial Team added an answer You can do this using ADO.Net DataTable. Concurrency issues need… May 17, 2026 at 1:53 am

Trending Tags

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

Top Members

Related Questions

I am completely new to regular expressions so I'm looking for a bit of
I am new to regex expressions so sorry if this is a really noob
I am a bit new to javascript and was trying to understand how the
How would you normalize all new-line sequences in a string to one type? I'm
I'm looking for a way to do a substring replace on a string in
Bit of oddness, seen if I do the following: import javax.swing.*; public class FunkyButtonLayout
I have a feeling my problem is a bit strange, but here goes... I
So for starters lets say that I have a LinkedList<String> , I can easily
I'd like to extract a date from any string entered. But not specific to
I am looking for an articles which introduce Intel 64 bit processor and Assembly:

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.