<input type="text" name="VV.engineNo" id="VV.engineNo" maxlength="30"value="S9911" title="" readonly="readonly"class='input_w w_p30' /> VB 通过xmlhttp 取得的html数据,不知道怎么写正则可以提取出 VV.engineNo 的value
Function RegExpTest(patrn, strng)
Dim regEx, Match, Matches ' 建立变量。
Set regEx = New RegExp ' 建立正则表达式。
regEx.Pattern = patrn ' 设置模式。
regEx.IgnoreCase = True ' 设置是否区分字符大小写。
regEx.Global = True ' 设置全局可用性。
Set Matches = regEx.Execute(strng) ' 执行搜索。
For Each Match In Matches ' 遍历匹配集合。
'RetStr = RetStr & "Match found at position "
'RetStr = RetStr & Match.FirstIndex & ". Match Value is '"
RetStr = RetStr & Match.Value
Next
RegExpTest = RetStr
End Function
Function RegExpTest(patrn, strng)
Dim regEx, Match, Matches ' 建立变量。
Set regEx = New RegExp ' 建立正则表达式。
regEx.Pattern = patrn ' 设置模式。
regEx.IgnoreCase = True ' 设置是否区分字符大小写。
regEx.Global = True ' 设置全局可用性。
Set Matches = regEx.Execute(strng) ' 执行搜索。
For Each Match In Matches ' 遍历匹配集合。
'RetStr = RetStr & "Match found at position "
'RetStr = RetStr & Match.FirstIndex & ". Match Value is '"
RetStr = RetStr & Match.Value
Next
RegExpTest = RetStr
End Function
把整段input 数据都出来了,不是单独的值
Private Sub TestReg()
Dim strData As String
Dim reg As Object
Dim matchs As Object, i As Integer, j As Integer
strData = "<input type=""text"" name=""VV.engineNo"" id=""VV.engineNo"" maxlength=""30""value=""S9911"" title="""" readonly=""readonly""class='input_w w_p30' />"
Set reg = CreateObject("vbscript.regExp")
reg.Global = True
reg.IgnoreCase = True
reg.MultiLine = True
reg.Pattern = "<input[^>]*?value=""(.*?)""[^>]*?>"
Set matchs = reg.Execute(strData)
For i = 0 To matchs.Count - 1
Debug.Print i + 1 & "." & matchs(i)
For j = 0 To matchs(i).SubMatches.Count - 1
Debug.Print "(" & j + 1 & ")." & matchs(i).SubMatches(j) & " ";
Next
If matchs(i).SubMatches.Count > 0 Then Debug.Print
Next
End Sub