国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > ASP > 正文

Highlight patterns within strings

2020-07-27 13:10:26
字體:
來源:轉載
供稿:網友

復制代碼 代碼如下:

'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

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 郎溪县| 湘乡市| 宁津县| 博白县| 桃园市| 桐柏县| 舟曲县| 苏尼特左旗| 石楼县| 庄浪县| 色达县| 丹棱县| 革吉县| 柳州市| 漳州市| 青河县| 湖南省| 郑州市| 元朗区| 威海市| 余庆县| 织金县| 宣威市| 都昌县| 五河县| 拜泉县| 登封市| 新绛县| 桐庐县| 达拉特旗| 龙游县| 同德县| 顺义区| 巧家县| 准格尔旗| 抚宁县| 隆尧县| 广安市| 疏附县| 太原市| 贺兰县|