Recommended: How to replace Replace in ASP in case insensitive Let's first look at the detailed parameter description of Replace Return string, where a specified number of substrings is replaced with another substring. Syntax Replace(expression, find, replace with[, compare[, count[, start]]]]) The syntax of the Replace function has the following parameters: Parameter description expression Required. String expression package
Normal replacement function
The code is as follows:public function HighLight(S,F)
dim tL,tM,tR,k
tL=
tM=
tR=S
k=instr(1,tR,F,1)
do while k>0
tL=tL & left(tR,k-1)
tM=mid(tR,k,len(F))
tL=tL & <span style='color:red'> & tM & </span>
tR=right(tR,Len(tR)-len(F)-k+1)
k=instr(1,tR,F,1)
loop
HighLight=tL & tR
end function
tS=abcaBcabCaBCabcaBCa
tF=bc
response.Write(tS)
response.Write(<br/>)
response.Write(HighLight(tS,tF))
Regular expressions
The code is as follows: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'>$1</span>)
End Function
Response.write HighLight(abcaBcabCaBCabcaBCa,bc)
Share: Use ASP to plan chat rooms I'm afraid few netizens who often surf the Internet have never been to the chat room to chat randomly. Just pay a little attention and you will find that most of these chat rooms are maintained using CGI programs or Applets developed in Java. Programmers who have developed this type of CGI or Applet know that