I need some help with regular expressions please. (In .Net 4 and C#)
I need to highlighting a block of text. The text is formated html so I am trying to use a regular expression to find the block when I just know the words in it. Then I want to put span tags around it:
For example if I have :
Now x is y the time z for all <bold>quick</bold> brown x foxes to jump over the lazy dogs back"
And I want to highlight “all quick brown foxes”
I want my result string to be:
Now x is y the time z for all <span class="MyHighLight"><bold>quick</bold> brown x foxes</span> to jump over the lazy dogs back"
The tricky part is I need to keep the original text, just put spans tags around it.
I thought I would start with replacing the spaces in the string I want to find with ?* to convert it to a regular expression.
all?*quick?*brown?*foxes
Thanks!
The result in console is:
Now x is y the time z for <span class=yellow>all <bold>quick</bold> brown foxes</span> to jump over the lazy dogs back