搜索结果日本@乳汁_实现搜索结果的关键词变色标注的程序(使用正则表达式)

更新时间:2013-12-19    来源:全文检索    手机版     字体:

【www.bbyears.com--全文检索】

<%
" 以前写全文检索程序的时候写的.
" 原创 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

本文来源:http://www.bbyears.com/aspjiaocheng/2809.html