28,390
社区成员
发帖
与我相关
我的任务
分享
<%
strng=",,2,23,#2,,,"
function formatstr(re,str,slink)
Set regex = New RegExp
regex.Pattern =re
regex.IgnoreCase = True ' 设置是否区分字符大小写。
regex.Global = True ' 设置全局可用性。
Set Matches = regex.Execute(str) ' 执行搜索。
For Each Match in Matches ' 遍历匹配集合。
if RetStr="" then
RetStr =Match.Value
else
RetStr = RetStr&slink& Match.Value
end if
Next
formatstr=RetStr
Set regex = Nothing
end function
response.Write formatstr("[\d]{1,}",strng,",")
%>
<%
strng=",,2,23,#2,,,"
function formatstr(re,str,slink)
Set regex = New RegExp
regex.Pattern =re
regex.IgnoreCase = True ' 设置是否区分字符大小写。
regex.Global = True ' 设置全局可用性。
Set Matches = regex.Execute(str) ' 执行搜索。
For Each Match in Matches ' 遍历匹配集合。
if RetStr="" then
RetStr =Match.Value
else
RetStr = RetStr&slink& Match.Value
end if
Next
Set regex = Nothing
response.Write formatstr("[\d]{1,}",strng,",")
%>
'给你一个简单,一个正则搞定
function findhtml(pd,str)
dim sheng_url
Set objRegExp1 = New Regexp
objRegExp1.IgnoreCase = True
objRegExp1.Global = True
objRegExp1.Pattern = pd
set mm=objRegExp1.Execute(str)
For i= 0 to mm.count -1
sheng_url=sheng_url&objRegExp1.Replace(mm.item(i),"$1")
Next
set objRegExp1=nothing
findhtml=sheng_url
end function
dim str,pd,pid
str=",,2,23,#2,,, "
'正则获取ID值
pid=findhtml("([\d]+,)",str)
pid=left(pid,len(pid)-1) '去掉最的一个,
'输出值
response.write pid
'结果显示如下:2,23,2
a = ",,2,23,#2,,,"
Dim regex
Set regex = New RegExp
regex.Pattern = "[^\d,]"
regex.Global = True
a = regex.Replace(a, "")
regex.Pattern = "[,]{2,}"
a = regex.Replace(a, ",")
regex.Pattern = "(,$)|(^,)"
a = regex.Replace(a, "")
Set regex = Nothing
MsgBox a
Dim regex
Set regex = New RegExp
regex.Global = True ' 上面少了
regex.Pattern = "[^\d,]"
str = regex.Replace(str, "")
regex.Pattern = "^\,+|\,+$|(\,)\,*"
str = regex.Replace(str, "$1")
Set regex = Nothing
<%
strng=",,2,23,#2,,,"
Set regex = New RegExp
regex.Pattern = "[\d]{1,}"
regex.IgnoreCase = True ' 设置是否区分字符大小写。
regex.Global = True ' 设置全局可用性。
Set Matches = regex.Execute(strng) ' 执行搜索。
For Each Match in Matches ' 遍历匹配集合。
if RetStr="" then
RetStr =Match.Value
else
RetStr = RetStr&","& Match.Value
end if
Next
Set regex = Nothing
response.Write RetStr
%>
Dim regex
Set regex = New RegExp
regex.Pattern = "[^\d,]"
str = regex.Replace(str, "")
regex.Pattern = "^\,+|\,+$|(\,)\,*"
str = regex.Replace(str, "$1")
Set regex = Nothing