最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

asp 關(guān)鍵詞高亮顯示(不區(qū)分大小寫)

 更新時間:2009年03月04日 23:46:27   作者:  
用ASP做搜索很容易,但要實現(xiàn)智能搜索這類就比較累一點,其實任何程序都差不多,主要還是看數(shù)據(jù)庫的處理能力,一般小網(wǎng)站ASP經(jīng)常跟ACCESS數(shù)據(jù)庫搭配
在這種配置下我們要實現(xiàn)關(guān)鍵詞不區(qū)分大小寫搜索并高亮顯示要借助ASP的正則處理了,請看下面代碼:
復(fù)制代碼 代碼如下:

<%
Function Takeout(patrn,string1,colors)
'提取搜索關(guān)鍵字匹配文字
Dim regEx, Match, Matches, tt ' 建立變量。
Set regEx = New RegExp ' 建立正則表達(dá)式。
regEx.Pattern = patrn ' 設(shè)置模式。
regEx.IgnoreCase = True ' 設(shè)置是否區(qū)分大小寫。
regEx.Global = True ' 設(shè)置全局可用性。
Set Matches = regEx.Execute(string1) ' 執(zhí)行搜索。
For Each Match in Matches ' 遍歷 Matches 集合。
RetStr = RetStr & Match.Value & " "
Next
RetStr = trim(RetStr)
if instr(RetStr," ")>0 then
for tt = 0 to ubound(split(RetStr," "))
string1 = replace(string1,split(RetStr," ")(tt),"<font color="""&colors&""">"&split(RetStr," ")(tt)&"</font>")
next
else
string1 = replace(string1,RetStr,"<font color="""&colors&""">"&RetStr&"</font>")
end if
Takeout = string1
End Function
response.write Takeout("jOeKOe", "Joekoe喬客雙語版","red")
Function Highlight(strContent,keyword) '標(biāo)記高亮關(guān)鍵字
Dim RegEx
Set RegEx=new RegExp
RegEx.IgnoreCase =True '不區(qū)分大小寫
RegEx.Global=True
Dim ArrayKeyword,i
ArrayKeyword = Split(keyword," ")'用空格隔開的多關(guān)鍵字
For i=0 To Ubound(ArrayKeyword)
RegEx.Pattern="("&ArrayKeyword(i)&")"
strContent=RegEx.Replace(strContent,"<font color=red>$1</font>" )
Next
Set RegEx=Nothing
Highlight=strContent
End Function
response.write Highlight("Joekoe喬客雙語版","jOeKOe")
%>

相關(guān)文章

最新評論

鲁甸县| 平舆县| 那曲县| 邹平县| 麻阳| 丰县| 东乡县| 榕江县| 通辽市| 临江市| 宁化县| 肥城市| 平南县| 鹰潭市| 绥棱县| 健康| 库尔勒市| 林甸县| 彭泽县| 依兰县| 藁城市| 香格里拉县| 娱乐| 通海县| 永川市| 宁国市| 竹溪县| 福清市| 札达县| 天门市| 朔州市| 合江县| 峨边| 邵东县| 华亭县| 婺源县| 文山县| 平泉县| 大关县| 五家渠市| 会同县|