|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
本帖最后由 zongyj 于 2014-12-3 13:37 编辑
英超数据,请问老师正则中(.*?)a+........(.*?)a+怎么简化- Sub yc()
- Dim htm1 As New XMLHTTP
- Dim str As String, ar
- Dim reg As New RegExp
- Dim arr
- Dim i, j, m, n
- Sheet4.Cells(4, 1).Resize(65533, 20).ClearContents
- With htm1
- .Open "POST", "http://cn.zso8.com/odds/search/", False
- .setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
- .setRequestHeader "Referer", "http://cn.zso8.com/odds/search/"
- .send "type=2&CompanyID=11%7C%E6%BE%B3%E9%97%A8&leagueID=36&teamID=0&kind=1&port=&odds1=&do0=%E7%A1%AE%E5%AE%9A"
- str = .responseText
- Debug.Print str
- End With
- With reg
- .Global = True
- .MultiLine = True
- .Pattern = "\s"
- str = .Replace(str, "")
- .Pattern = ".*?(<trid.*)"
- str = .Replace(str, "$1")
- .Pattern = " "
- str = .Replace(str, "")
- .Pattern = "<tr.*?>"
- str = .Replace(str, "y")
- .Pattern = "<.*?>"
- str = .Replace(str, "a")
- Debug.Print str
- .Pattern = "ya+(.*?)a+(.*?)a+(.*?)a+(.*?)a+(.*?)a+(.*?)a+(.*?)a+(.*?)a+(.*?)a+(.*?)a+(.*?)a+(.*?)a+(.*?)a+(.*?)a+(.*?)a+(.*?)a+(.*?)a+(.*?)a+(.*?)a+(.*?)a+"
- Set ar = .Execute(str)
- ReDim arr(0 To ar.Count, 19)
- For i = 0 To ar.Count - 1
- For j = 0 To 19
- arr(i, j) = ar.Item(i).SubMatches(j)
- Next
- Next
- n = Sheet4.Range("a65533").End(xlUp).Row
- Sheet4.Cells(n + 1, 1).Resize(ar.Count - 1, 20) = arr
- End With
- End Sub
复制代码 |
|