So I'm replacing all instances of a word in a string ignoring the case:
public static String ReplaceAll(String Input, String Word)
{
string Pattern = string.Format(@"\b{0}\b", Word);
Regex rgx = new Regex(Pattern, RegexOptions.IgnoreCase);
StringBuilder sb = new StringBuilder();
sb.Append(rgx.Replace(Input, string.Format("<span class='highlight'>{0}</span>", Word)));
return sb.ToString();
}
What I also need is the replace to keep the found words case, so if I'm looking for 'this' and RegEx finds 'This' it will replace the found word as 'This' and not 'this', I've done this before but it was a few years ago and in javascript, having a little trouble working it out again.