I wrote little class that highlight values in string wrapping them in <span> tag with specific class. Notice that regex will not touch text inside html tags. So text "<div someValue>someValue</div>" will become "<div someValue><span class=''highlight'>someValue</span></div>".
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Text.RegularExpressions;
public static class Highlighter
{
private const string MatchPattern = "(?<!<[^>]*)(?<matched>{0})";
private const string ReplacePattern = "<span class='highlight'>${matched}</span>";
public static string Highlight(string value, string pattern)
{
var patternEsc = string.Format(MatchPattern, Regex.Escape(pattern));
return Regex.Replace(value, patternEsc, ReplacePattern, RegexOptions.IgnoreCase);
}
}
Harrah's Reno- Casino - JMT Hub
ОтветитьУдалитьHarrah's Reno Casino is an iconic and historic Reno-Tahoe destination. 전라북도 출장안마 As the 화성 출장샵 name 거제 출장마사지 implies, 거제 출장샵 the hotel boasts 수원 출장안마 a 3,000 seat