Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex 如何在Vb.net表单中显示html标记之间的值_Regex_Vb.net_Webclient_Vb.net 2010 - Fatal编程技术网

Regex 如何在Vb.net表单中显示html标记之间的值

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

我想从我的vb.net表单中的网站中提取字体标记之间的数字

<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,}周围的括号)

问候