I've got the following code:
Regex.Replace(text, words.ToString(), "<dfn title=\"" + this.FindDefinition("$0") + "\">$0</dfn>", RegexOptions.IgnoreCase | RegexOptions.Compiled);
The problem I'm having is with the FindDefinition method. I would like to send in the originale word to make a lookup and return the definition text. Is this possible or do I need to create a template like this:
Regex.Replace(text, words.ToString(), "<dfn title=\"{$0}\">$0</dfn>", RegexOptions.IgnoreCase | RegexOptions.Compiled);
And then do a search for it to replace it with my definition?
I've also tried with:
Regex.Replace(text, words.ToString(), this.ReplaceWord, RegexOptions.IgnoreCase | RegexOptions.Compiled);
private string ReplaceWord(Match m)
{
return "<dfn title=\"" + this.FindDefinition(m.Value) + "\">$0</dfn>";
}
Which works fine with the FindDefinition method, but then I have a problem getting the original value.
Anything I'm missing?