复制代码 代码如下:'Replaces pattern with highlighted replacement (using style) and preserves case Public Function highlight(strText, strFind) Dim objRegExp, i, strHighlight 'Split the search terms into an array Dim arrFind arrFind = Split(strFind, " ") 'Initialize the regular expression object to perfom the search Dim oMatches, sMatch Set oregExp = New RegExp oregExp.Global = True 'Returns all matches to the search term oregExp.IgnoreCase = True 'Case insensitive 'Loop through the array of search terms to find matches For i = 0 to UBound(arrFind) oregExp.Pattern = arrFind(i) 'Sets the search pattern string Set oMatches = oregExp.Execute(strText) '// performs the search for each match in oMatches 'Build the code to be used to highlight results strHighlight = "<span class=""highlight"">" & match.value & "</span>" next 'Replace matches from the search with the above code strText = oregExp.Replace(strText, strHighlight) Next highlight = strText Set objRegExp = Nothing End Function
推荐阅读
ASP下实现自动采集程序及入库的代码
最近网上流行着一些采集程序,更多人拿着这些东西在网上叫卖,很多不太懂的人看着那些程序眼羡,其实如果你懂一些ASP,了解自动采集程序的原理后,你会感觉实现自动化也是那么的简单. 原理及优点:通过XML中的XMLHTTP组件>>>详细阅读
本文标题:Highlight patterns within strings
地址:http://www.17bianji.com/kaifa2/ASP/32598.html
1/2 1