如何高亮显示关键字
来源:互联网 发布:qq飞车爆天甲数据 编辑:程序博客网 时间:2024/06/09 04:44
<%
' 以前写全文检索程序的时候写的.
' 原创 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
%>
' 以前写全文检索程序的时候写的.
' 原创 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
%>
- 如何高亮显示关键字
- 高亮显示关键字
- 高亮显示关键字
- 高亮显示关键字
- 高亮显示关键字
- 关键字高亮显示
- 关键字高亮显示
- 关键字高亮显示
- 关键字高亮显示
- 关键字高亮显示
- 关键字高亮显示
- Lucene关键字高亮显示
- js 关键字 高亮 显示
- js高亮显示关键字
- eclipse 关键字高亮显示
- AndroidTextview关键字高亮显示
- 搜索关键字显示高亮
- 与关键字的高亮显示相关
- 设计用例
- 复杂性话题之总结
- windows下使用makefile编译C语言.doc
- 收集的CSS仿经典下拉菜单
- SQL server2000 安装文件挂起错误的解决办法
- 如何高亮显示关键字
- XML基础
- sql中压缩日志文件和ntextl转化为varchar的处理(downmoon)
- 163改版了~~
- How Servlet Containers Work?
- 生命是一种长期而持续的累积过程
- Linux内核的同步机制 --转载
- ORACLE TKPROF使用步骤
- [全程建模]新一期全程建模培训顺利完成