普通的替换函数
代码如下:
public function HighLight(S
F)
dim tL
tM
tR
k
tL=""
tM=""
tR=S
k=instr(
tR
F
)
do while k>
tL=tL & left(tR
k
)
tM=mid(tR
k
len(F))
tL=tL & "<span style=
color:red
>" & tM & "</span>"
tR=right(tR
Len(tR)
len(F)
k+
)
k=instr(
tR
F
)
loop
HighLight=tL & tR
end function
tS="abcaBcabCaBCabcaBCa"
tF="bc"
response
Write(tS)
response
Write("<br/>")
response
Write(HighLight(tS
tF))
正则表达式
代码如下:
Function HighLight(S
F)
Dim regEx
Set regEx = New RegExp
regEx
IgnoreCase = True
regEx
Global = True
regEx
Pattern = "(" & F & ")"
HighLight = regEx
Replace(S
"<span style=
color:red
>$
</span>")
End Function
Response
write HighLight("abcaBcabCaBCabcaBCa"
"bc")