I have a dictionary collection that stores the starting position and the charecter values of a text file.
For example: a sample text file (a.txt) may contain text like “how are you? how do you do?”
I have indexed the above text as follows
Dictionary<long,string> charLocation = new Dictionary<long,string>();
charLocation[0] = "how"
charLocation[1] = "ow"
charLocation[2] = "w"
charLocation[4] = "are"
charLocation[6] = "e"
charLocation[5] = "re"
charLocation[11] = "?"
charLocation[9] = "ou?"
charLocation[10] = "u?"
charLocation[8] = "you?"
charLocation[13] = "how"
charLocation[14] = "ow"
charLocation[15] = "w"
charLocation[17] = "do"
charLocation[18] = "o"
charLocation[21] = "ou"
charLocation[22] = "u"
charLocation[20] = "you"
charLocation[26] = "?"
charLocation[24] = "do?"
charLocation[25] = "o?"
Now, I want to highlight each occurrence of “how” or “do” in the text file.
For this I want to first do a lookup in the dictionary collection and find each occurrence of the string, then open the text file and highlight the text for each occurrence.
How can i do this?
Not tested, but this should works.
So you could do :
And if my code has no errors, that would returns “
<strong>how</strong>are you?<strong>how</strong>do you do?”;Then you can repalce
<strong>and</strong>with wathever you want to “highlight” your text.