What would be the best way to search HTML inside a C # string variable to find a specific word / phrase and mark (or wrap) that word / phrase with highlighted color?
Thanks,
Jeff
I like to use the Html Agility Pack is very easy to use, although recently there are not many updates in it, it can still be used. For example, capturing all links
HtmlWeb client = new HtmlWeb(); HtmlDocument doc = client.Load("http://yoururl.com"); HtmlNodeCollection Nodes = doc.DocumentNode.SelectNodes("//a[@href]"); foreach (var link in Nodes) { Console.WriteLine(link.Attributes["href"].Value); }
Regular expression will be my way .;)
HTML, XHTML-, XML-, XPath/XSL - , ?
, , HTMLTidy HTML XHTML, XSL/XPath , .
, , , .., .
.
string input = "ttttttgottttttt";string output = Regex.Replace(, "go", "<strong> $0 </strong> " );
: "tttttt <strong> go </strong> ttttttt"
HTML, , . , HTML:
< span class= "firstLetter" > B </span> ook
"", HTML. , , , .
Html DOM - SourceForge.net. , .
Search strings, you need to search for regular expressions. As for labeling, after you have a substring position, it should be simple enough to use this to add something to wrap a phrase.