28,409
社区成员




<%
' ExpStr(vStr,vReg,sStr)
' 返回正则匹配结果
'
' #####################################################
'
' vStr 为原始字符串
' vReg 为正则表达式
' sStr 为分隔符(尽量使用原始字符串中不会出现的字符串)
'
' #####################################################
'
' a = ExpStr("<a href=Functions.asp>函数库地址</a><br><a href=http://www.x-bs.com>文盲的演示代码</a>","<a[^<>]*>[^<>]*?(</a>)","||")
' IsArray(a) ' Return True
' UBound(a) ' Return 1
' a(0) ' Return "<a href=Functions.asp>函数库地址</a>"
' a(1) ' Return "<a href=http://www.x-bs.com>文盲的演示代码</a>"
Function ExpStr(vStr,vReg,sStr)
Dim Re,Matchs,Item,tStr
tStr = ""
Set Re = New RegExp
Re.Pattern = vReg
Re.IgnoreCase = True
Re.Global = True
If Re.Test(vStr) Then
Set Matchs = Re.Execute(vStr)
For Each Item In Matchs
tStr = tStr & Item.Value & sStr
Next
tStr = Split(Left(tStr,Len(tStr) - Len(sStr)),sStr)
End If
Set Re = Nothing
ExpStr = tStr
End Function
%>
'//以下代码徒手写的,仅仅是大概思路
Do
IntBegin =Instr(StrWebCode,"<span>") + Len("<span>")
If IntBegin < Len("<span>") then Exit DO
IntEnd = Instr(StrWebCode,"</span>")
IF IntEnd < 0 Then Go To Err: '//OR Exit DO
StrAllGet = StrAllGet & Mid(StrWebCode,IntBegin,IntEnd-IntBengin) & "##"
Loop
LastArray=split(StrAllGet,"##") '//这样就不会上下标越界,而且可以得到所有<span>值.