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

首頁 > 編程 > ASP > 正文

Highlight patterns within strings

2024-05-04 11:01:41
字體:
來源:轉載
供稿:網友

復制代碼 代碼如下:
'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

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 南皮县| 丰原市| 奉化市| 兴和县| 林芝县| 方正县| 舞阳县| 巴林右旗| 塔河县| 龙胜| 长岭县| 商城县| 宾阳县| 区。| 方正县| 正镶白旗| 牡丹江市| 阿克| 都匀市| 永修县| 英吉沙县| 西吉县| 修武县| 广安市| 临朐县| 天全县| 乐至县| 广水市| 吴川市| 双流县| 措勤县| 玉溪市| 山阴县| 衡水市| 祁阳县| 晋中市| 温泉县| 吴桥县| 温泉县| 外汇| 沙河市|