7,763
社区成员
发帖
与我相关
我的任务
分享
Option Explicit
Function TestRegExp(myPattern As String, myString As String)
''Create objects.
Dim objRegExp As RegExp
Dim objMatch As Match
Dim colMatches As MatchCollection
Dim RetStr As String
'' Create a regular expression object.
Set objRegExp = New RegExp
''Set the pattern by using the Pattern property.
objRegExp.Pattern = myPattern
'' Set Case Insensitivity.
objRegExp.IgnoreCase = True
''Set global applicability.
objRegExp.Global = True
''Test whether the String can be compared.
If (objRegExp.Test(myString) = True) Then
''Get the matches.
Set colMatches = objRegExp.Execute(myString) '' Execute search.
For Each objMatch In colMatches '' Iterate Matches collection.
' RetStr = RetStr & "position "
' RetStr = RetStr & objMatch.FirstIndex & ". Match Value is ''"
RetStr = RetStr & objMatch.Value & "" & vbCrLf
Next
Else
RetStr = "String Matching Failed"
End If
TestRegExp = RetStr
End Function
Private Sub Command1_Click()
Dim strurl As String
Dim xmlobject As Object
Dim strHTML As String
Dim RegStrName As String
strurl = "http://bbs.duowan.com/thread-17923560-3-1.html"
Set xmlobject = CreateObject("Microsoft.XMLHTTP")
xmlobject.Open "GET", strurl, False
xmlobject.Send
If xmlobject.readyState = 4 Then
strHTML = xmlobject.Responsetext
End If
' showMenu(this.id)">名字</a></cite>
RegStrName = (TestRegExp("showMenu+[\S]+</a>", strHTML))
Debug.Print RegStrName
End Sub
Option Explicit
Function TestRegExp(myPattern As String, myString As String)
''Create objects.
Dim objRegExp As RegExp
Dim objMatch As Match
Dim colMatches As MatchCollection
Dim RetStr As String
'' Create a regular expression object.
Set objRegExp = New RegExp
''Set the pattern by using the Pattern property.
objRegExp.Pattern = myPattern
'' Set Case Insensitivity.
objRegExp.IgnoreCase = True
''Set global applicability.
objRegExp.Global = True
''Test whether the String can be compared.
If (objRegExp.Test(myString) = True) Then
''Get the matches.
Set colMatches = objRegExp.Execute(myString) '' Execute search.
For Each objMatch In colMatches '' Iterate Matches collection.
' RetStr = RetStr & "position "
' RetStr = RetStr & objMatch.FirstIndex & ". Match Value is ''"
RetStr = RetStr & objMatch.Value & "" & vbCrLf
Next
Else
RetStr = "String Matching Failed"
End If
TestRegExp = RetStr
End Function
Private Sub Command1_Click()
Dim strurl As String
Dim xmlobject As Object
Dim strHTML As String
Dim RegStrName As String
strurl = "http://bbs.duowan.com/thread-17923560-3-1.html"
Set xmlobject = CreateObject("Microsoft.XMLHTTP")
xmlobject.Open "POST", strurl, False
xmlobject.Send
If xmlobject.readyState = 4 Then
strHTML = xmlobject.Responsetext
End If
' showMenu(this.id)">名字</a></cite>
RegStrName = (TestRegExp("showMenu.this.id.+[\S]+</a></cite>", strHTML))
Debug.Print RegStrName
End Sub