相思资源网 Design By www.200059.com
有段字符串: asdfasdlfajsodf{#kljlkkm#}ojgvjfkdsf{#wdfs#}llsdflksdf
没任何规律的...我要把里面的{#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
%>
没任何规律的...我要把里面的{#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,截取字符串
相思资源网 Design By www.200059.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
相思资源网 Design By www.200059.com
暂无用asp实现的截取指定格式字符串的代码的评论...