作家
登录

Highlight patterns within strings

作者: 来源:www.28hudong.com 2013-03-30 08:41:55 阅读 我要评论

复制代码 代码如下:'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

关键词: 探索发现

乐购科技部分新闻及文章转载自互联网,供读者交流和学习,若有涉及作者版权等问题请及时与我们联系,以便更正、删除或按规定办理。感谢所有提供资讯的网站,欢迎各类媒体与乐购科技进行文章共享合作。

网友点评
自媒体专栏

评论

热度

精彩导读
栏目ID=71的表不存在(操作类型=0)