- 关 键 词:
- rip
<%
' 以前写全文检索程序的时候写的.
' 原创 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
%>URL:http://www.qqread.com/asp/u702986001.html进入讨论组讨论。
相关图文阅读
频道图文推荐
健 康 咨 询
时 尚 咨 询
相关专题
- asp检测文件编码 (0次浏览)
- ASP发送邮件的class(完) (0次浏览)
- Asp常见问题(新手) (0次浏览)
- asp编译成dll-图形化教程 (0次浏览)
- ASP编程入门进阶 (0次浏览)
- Asp备份与恢复SQL Server数据库 (0次浏览)
- Asp+的几个特点 (0次浏览)
- ASP:在结果中搜索 (0次浏览)
- asp 中对 ip 进行过滤限制函数 (0次浏览)
- ASP 指南 (0次浏览)



