protected string HighlightText(string searchWord, string inputText)
{
Regex expression = new Regex(searchWord.Replace(" ", "|"));
// Regex.ignorecase
return expression.Replace(inputText, new MatchEvaluator(ReplaceKeywords));
}
public string ReplaceKeywords(Match m)
{
return "<span class='highlight'>" + m.Value + "</span>";
}
Programming Journal C#, Java, SQL and to a lesser extent HTML, CSS, XML, and regex. I made this so other programmers could benefit from my experience.
Friday, September 14, 2007
Highlight search text functions using css tags and regex
Subscribe to:
Post Comments (Atom)
Blog Archive
-
▼
2007
(41)
-
▼
September
(13)
- Connecting to Kensoft.net SQL Server 2005 database
- Copying a MDF SQLExpress Database file to SQL Serv...
- Building an AJAX Slide Show in ASP.net
- Proper ViewState use and the coalescing operator
- GridView table headers and iterating over a GridVi...
- DataGridView cell contents and header contents
- HTML Table header accessibility standards
- C# switch statement for DropDownList to update Ima...
- Using XPath for reading attribute and content of XML
- Nested GridView with subtotals, totals, and counts
- Modifying the contents of a GridView after DataBin...
- Highlight search text functions using css tags and...
- C# to run stored procedure after parsing text
-
▼
September
(13)
No comments:
Post a Comment