人人做人人澡人人爽欧美,国产主播一区二区,久久久精品五月天,羞羞视频在线观看免费

當前位置:蘿卜系統下載站 > 技術開發教程 > 詳細頁面

完成搜索結果的關鍵詞變色標注的程序(運用正則表達式)

完成搜索結果的關鍵詞變色標注的程序(運用正則表達式)

更新時間:2022-08-01 文章作者:未知 信息來源:網絡 閱讀次數:


<%
' 以前寫全文檢索程序的時候寫的.
' 原創 by 飛鳥@dev-club.com
' Email: flybird@dev-club.com
' ie5.5 腳本引擎 required

    dim patern
    dim found
    
    dim str
    dim result
    
    patern="(a)|(b)"
    str=" A dog fall in love with a cat. Can you believe?"
    result=""    
    call getMatchText(str,result,false)
    Response.Write result

    sub getMatchText(byref str,byref result,isNeedTrunc)
        'on error resume next
        Dim regEx, Match, Matches
        dim tStr
        Set regEx = New RegExp         ' 建立正則表達式。        
        regEx.Pattern = (patern)    ' 設置模式。
        regEx.IgnoreCase = True         ' 設置是否區分字符大小寫。
        regEx.Global = True         ' 設置全局可用性。
        Set Matches = regEx.Execute(str)   ' 執行搜索。    
        if err.number<>0 then
            response.write "錯誤1:" & err.description
            err.clear
            exit sub
        end if
        if matches.count <>0 then
            dim startIndex            
            dim myMatchValue
            startIndex=1
            for each match in matches
                if (instr(str,match.value)>0) then
                    if instr(str,match.value)-50 >0 then
                        startIndex=instr(str,match.value)-50
                    else
                        startIndex=1
                    end if
                    myMatchValue=match.value
                    exit for
                end if
            next
            if isNeedTrunc then
                result= (mid(str,startIndex,strLength(myMatchValue)+100))
            else
                result= (str)    
            end if
            for each match in matches
                if not(instr(result,"<font color=red>" & match.value & "</font>")>0) then
                    result=replace(result,match.value,"<font color=red>" & match.value & "</font>" )
                end if
            next
            found=true
        else
            found=false
        end if    
        set regEx=nothing
    end sub
    
%>

溫馨提示:喜歡本站的話,請收藏一下本站!

本類教程下載

系統下載排行

網站地圖xml | 網站地圖html
主站蜘蛛池模板: 攀枝花市| 五莲县| 微山县| 建平县| 桃江县| 水城县| 吉首市| 隆尧县| 淮阳县| 三台县| 北海市| 宿迁市| 荃湾区| 鄂托克前旗| 海口市| 苏州市| 堆龙德庆县| 正蓝旗| 镇原县| 海伦市| 汉源县| 永吉县| 凤翔县| 永清县| 当涂县| 涟源市| 蓝山县| 广河县| 嘉峪关市| 新营市| 晋中市| 铁岭市| 靖宇县| 阳城县| 辉南县| 新营市| 慈利县| 奉贤区| 财经| 湖北省| 无锡市|