有段字符串: asdfasdlfajsodf{#kljlkkm#}ojgvjfkdsf{#wdfs#}llsdflksdf
沒任何規(guī)律的...我要把里面的{#kljlkkm#}和{#wdfs#}查找出來...
1、Split辦法:
復制代碼 代碼如下:
%
Dim I, sCode, aCode, sNewCode
sCode = "asdfasdlfajsodf{#kljlkkm#}ojgvjfkdsf{#wdfs#}llsdflksdf"
aCode = Split(sCode, "{#")
sNewCode = ""
For I = 0 To UBound(aCode)
If InStr(aCode(I), "#}") > 0 Then sNewCode = sNewCode "{#" Split(aCode(I), "#}")(0) "#}"
Next
Response.Write sNewCode
%>
2、正則辦法:
復制代碼 代碼如下:
%
Dim sCode, sNewCode, oTempReg, Match, Matches
sCode = "asdfasdlfajsodf{#kljlkkm#}ojgvjfkdsf{#wdfs#}llsdflksdf"
Set TempReg = New RegExp
With TempReg
.IgnoreCase = True
.Global = True
.Pattern = "\{\#.+?\#\}"
Set Matches = .Execute(sCode)
For Each Match In Matches
sNewCode = sNewCode Match.Value
Next
End With
Set TempReg = Nothing
Response.Write sNewCode
%>
您可能感興趣的文章:- asp截取字符串的兩種應用
- asp下實現截取字符串特定部分內容函數
- asp 字符串截取函數
- GetBody asp實現截取字符串的代碼
- asp從字符串里截取N個帶HTML的字符的函數
- asp截取指定英漢混合字符串_支持中文
- ASP.NET 字符串截取
- asp CutStrX字符串截取函數(過濾全部HTML標記)
- asp實現截取字符串函數