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,
- startIndex = 3, Length = 10
- 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
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
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