Regex 如何在Vb.net表单中显示html标记之间的值
我想从我的vb.net表单中的网站中提取字体标记之间的数字Regex 如何在Vb.net表单中显示html标记之间的值,regex,vb.net,webclient,vb.net-2010,Regex,Vb.net,Webclient,Vb.net 2010,我想从我的vb.net表单中的网站中提取字体标记之间的数字 <html> ... When asked enter the code: <font color=blue>24006 </font> ... </html> ... 当询问时,输入代码:24006 ... 24006是自动生成的数字,可自动更改 我使用: Dim str As String = New WebClient().DownloadString(("http://ww
<html>
...
When asked enter the code: <font color=blue>24006 </font>
...
</html>
...
当询问时,输入代码:24006
...
24006是自动生成的数字,可自动更改
我使用:
Dim str As String = New WebClient().DownloadString(("http://www.example.com"))
Dim pattern = "When asked enter the code: <font color=blue>\d{5,}\s</font>"
Dim r = New Regex(pattern, RegexOptions.IgnoreCase)
Dim m As Match = r.Match(str)
If m.Success Then
Label1.Text = "Code" + m.Groups(1).ToString()
m = m.NextMatch()
Else
Debug.Print("Failed")
End If
Dim str As String=New WebClient()。下载字符串(“http://www.example.com"))
Dim pattern=“当要求时,输入代码:\d{5,}\s”
Dim r=新正则表达式(模式,RegexOptions.IgnoreCase)
尺寸m作为匹配=r.匹配(str)
如果m.成功了那么
Label1.Text=“Code”+m.Groups(1).ToString()
m=m.NextMatch()
其他的
Debug.Print(“失败”)
如果结束
但在Label1中得到了输出:
代码您必须设置捕获组。当被要求输入代码时,Regex应该是“
”(\d{5,})\s
(注意\d{5,}周围的括号)
问候