国产探花免费观看_亚洲丰满少妇自慰呻吟_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

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 巴彦县| 安康市| 伊宁市| 陆河县| 昭觉县| 安平县| 潜江市| 略阳县| 兴国县| 福鼎市| 双城市| 阜新市| 松溪县| 乌拉特前旗| 武城县| 金湖县| 波密县| 监利县| 玉门市| 仪征市| 双峰县| 玉田县| 亳州市| 安顺市| 吴忠市| 黔西| 海淀区| 绥棱县| 读书| 澄江县| 武宣县| 雷州市| 宁津县| 陕西省| 屯留县| 库尔勒市| 涟源市| 资中县| 徐水县| 新源县| 清新县|