The onclick='Odds (942058) :'
The onclick='Odds (942059) :'
The onclick='Odds (942060) :'
The onclick='Odds (942061) :'
I have a lot of a the text inside is similar to this appearance! I want to have all the Numbers are all behind the back up! In an array. How should do? Thank you for your attention!
By the way, I'm in a web page parsing program! So there will be a lot of "=" and "onclick"! There will be many other irrelevant data! So as far as possible can be serious!
CodePudding user response:
'this code by the " regular testing tools> v1.1.35 "generated automatically, please direct call TestReg process
Private Sub TestReg ()
Dim strData As String
Dim reg As Object
Dim matchs the As Object, the match As Object
StrData="https://bbs.csdn.net/topics/onclick=" Odds (942057) '" & amp; VbCrLf & amp; _
"Onclick='Odds (942058)'" & amp; VbCrLf & amp; _
"Onclick='Odds (942059)'" & amp; VbCrLf & amp; _
"Onclick='Odds (942060)'" & amp; VbCrLf & amp; _
"Onclick='Odds (942061)", "
The Set reg=CreateObject (" vbscript. RegExp ")
Reg. Global=True
Reg. The IgnoreCase=True
Reg. MultiLine=True
Reg. The Pattern="onclick='Odds \ ((\ d *) \'"
The Set matchs=reg. The Execute (strData)
For Each match matchs In
'Value
Debug. Print the match.The Debug. Print match. SubMatches (0)
Next
End Sub
CodePudding user response:
(?CodePudding user response:
Both Dim strDataAs String
Dim strLine () As String
Dim lngData () As Long
Dim As Long I
StrData="https://bbs.csdn.net/topics/onclick=" Odds (942057) '" & amp; VbCrLf & amp; _
"Onclick='Odds (942058)'" & amp; VbCrLf & amp; _
"Onclick='Odds (942059)'" & amp; VbCrLf & amp; _
"Onclick='Odds (942060)'" & amp; VbCrLf & amp; _
"Onclick='Odds (942061)", "
StrLine=Split (strData, vbCrLf)
ReDim lngData (UBound (strLine))
For I=0 To UBound (strLine)
LngData (I)=Val (Mid (strLine (I), 15))
The Debug. Print lngData (I)
Next I
run results
942057
942058
942059
942060
942061
CodePudding user response:
First of all, is the data by only onclick='Odds (942057)'The onclick='Odds (942058) :'
The onclick='Odds (942059) :'
The onclick='Odds (942060) :'
The onclick='Odds (942061) :'
This kind of data, if it is right, not, you consider clear problem,
Vb6 architecture
With an array of strings first load the onclick='Odds (942059)' the data
Then loop of string with the split according to the resolution of the "="
The string after taking 'Odds (942059)'
Then use the replace 'Odds (and)' replace
The last is the number you want,
Vb6 use regular expressions seem quite troublesome,
CodePudding user response:
Since using split, not directly use "(" split:Both Dim strData
As String
Dim strLine () As String, strItem () As String
Dim lngData () As Long
Dim As Long I
StrData="https://bbs.csdn.net/topics/onclick=" Odds (942057) '" & amp; VbCrLf & amp; _
"Onclick='Odds (942058)'" & amp; VbCrLf & amp; _
"Onclick='Odds (942059)'" & amp; VbCrLf & amp; _
"Onclick='Odds (942060)'" & amp; VbCrLf & amp; _
"Onclick='Odds (942061)", "
StrLine=Split (strData, vbCrLf)
ReDim lngData (UBound (strLine))
For I=0 To UBound (strLine)
StrItem=Split (strLine (I), "(")
If UBound (strItem=1 Then
LngData (I)=Val (strItem (1))
The Debug. Print lngData (I)
End the If
Next I