熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

ASP標記的字符串指定變色不區分大小寫

2022-06-13   來源: .NET編程 

  普通的替換函數

代碼如下:
public function HighLight(SF)
dim tLtMtRk
tL=""
tM=""
tR=S
k=instr(tRF)
do while k>
tL=tL & left(tRk)
tM=mid(tRklen(F))
tL=tL & "<span style=color:red>" & tM & "</span>"
tR=right(tRLen(tR)len(F)k+)
k=instr(tRF)
loop
HighLight=tL & tR
end function
tS="abcaBcabCaBCabcaBCa"
tF="bc"
responseWrite(tS)
responseWrite("<br/>")
responseWrite(HighLight(tStF))

  正則表達式

代碼如下:
Function HighLight(SF)
Dim regEx
Set regEx = New RegExp
regExIgnoreCase = True
regExGlobal = True
regExPattern = "(" & F & ")"
HighLight = regExReplace(S"<span style=color:red>$</span>")
End Function
Responsewrite HighLight("abcaBcabCaBCabcaBCa""bc") 
From:http://tw.wingwit.com/Article/program/net/201311/14082.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.