ASP標(biāo)記的字符串指定變色不區(qū)分大小寫_ASP教程
教程Tag:暫無Tag,歡迎添加,賺取U幣!
推薦:ASP中Replace如何替換不區(qū)分大小寫我們先來看一看 Replace 的詳細(xì)參數(shù) 描述 返回字符串,其中指定數(shù)目的某子字符串被替換為另一個(gè)子字符串。 語法 Replace(expression, find, replacewith[, compare[, count[, start]]]) Replace 函數(shù)的語法有以下參數(shù): 參數(shù) 描述 expression 必選項(xiàng)。 字符串表達(dá)式 包
普通的替換函數(shù)
代碼如下:
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))
正則表達(dá)式
代碼如下:
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")
分享:利用ASP規(guī)劃聊天室經(jīng) 常 在Internet 上 沖 浪 的 網(wǎng) 友 恐 怕 很 少 有 人 沒 有 去 過 聊 天 室 胡亂神聊。 你 只 要 稍 微 留 意 一 下 就會(huì) 發(fā) 現(xiàn) 這 些 聊 天 室 大 多 是 用CGI 程 序 或 者 用java 開 發(fā) 的 Applet 維 護(hù) 的。 開 發(fā) 過 這 類CGI 或Applet 的 程 序 員 都 知 道,
相關(guān)ASP教程:
- asp FSO 讀寫文件本文件實(shí)現(xiàn)代碼
- asp中isNull、isEmpty和空字符串的區(qū)別
- asp獲取用戶真實(shí)IP地址的方法
- asp連接sqlserver數(shù)據(jù)庫實(shí)現(xiàn)代碼
- asp中正則表達(dá)式過濾html代碼函數(shù)
- asp中g(shù)et post提交表單區(qū)別
- 網(wǎng)頁模板:ASP內(nèi)建對象Request
- xmlhttp的open方法使用詳解
- ASP的常用的自定義函數(shù)大全
- asp中用for循環(huán)的一個(gè)小技巧
- eWebEditor v3.8 列目錄
- ASP無組件分頁實(shí)現(xiàn)思路及代碼
- 相關(guān)鏈接:
- 教程說明:
ASP教程-ASP標(biāo)記的字符串指定變色不區(qū)分大小寫
。