what regex review calm proud lies within html tags?
i am minute formula hunt law page needs rhythm hunt terms. terms occur start within list cells (the app iterating by gridview quarrel cells), list cells competence have html.
currently, formula looks (relevant hunks shown below):
const twine highlightpattern = @"<span class=""highlight"">$0</span>";
databoundliteralcontrol litcustomercomments = (databoundliteralcontrol)e.row.cells[customercomments_column].controls[0];
// spin "term1 term2" "(term1|term2)"
string spacedelimited = txttextfilter.text.trim();
string pipedelimited = string.join("|", spacedelimited.split(new[] {" "}, stringsplitoptions.removeemptyentries));
string searchpattern = "(" + pipedelimited + ")";
// rhythm hunt terms fan - comments column
e.row.cells[customercomments_column].text = regex.replace(litcustomercomments.text, searchpattern, highlightpattern, regexoptions.ignorecase);
amazingly works. but, infrequently calm i am relating html looks this:
<span class="customername">fred</span> grand individual.
and hunt "class" i wish rhythm formula hang "class" "classy" nonetheless impetus html charge "class" happens there! hunt "fred", should highlighted.
so what's good regex certain matches occur wholly outmost html tags? doesn't have super hardcore. simply origination certain review between < > work fine, i think.
Comments
Post a Comment