I am implementing a website search and am trying to highlight the words the user searched for using the below code:
data = Regex.Replace(data, Model.SearchCriteria, "<strong>" + Model.SearchCriteria + "</strong>", RegexOptions.IgnoreCase);
However if data is "I went North towards Canada" and the user has searched for "north" the results will show "I went north towards Canada" with north highlighted however the actual data has been replaced incorrectly slightly.
How can I keep the returned data in tact whilst higlighting what the user searched for?