Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/306.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
C# C Windows应用程序-如何跨越textbox1中显示的标记值?_C#_Regex_Getattribute_Htmlelements - Fatal编程技术网

C# C Windows应用程序-如何跨越textbox1中显示的标记值?

C# C Windows应用程序-如何跨越textbox1中显示的标记值?,c#,regex,getattribute,htmlelements,C#,Regex,Getattribute,Htmlelements,实际上,我想跨越显示在textbox1.Text区域中的数据值 这是完整的代码 <td id="yiv9101838563i4" style="padding:0;padding-top:25px;font-family:'Segoe UI', Tahoma, Verdana, Arial, sans-serif;font-size:14px;color:#2a2a2a;">Security code: <span style="font-family:'Segoe UI Bo

实际上,我想跨越显示在textbox1.Text区域中的数据值

这是完整的代码

<td id="yiv9101838563i4" style="padding:0;padding-top:25px;font-family:'Segoe UI', Tahoma, Verdana, Arial, sans-serif;font-size:14px;color:#2a2a2a;">Security code: <span style="font-family:'Segoe UI Bold', 'Segoe UI Semibold', 'Segoe UI', 'Helvetica Neue Medium', Arial, sans-serif;font-size:14px;font-weight:bold;color:#2a2a2a;">7201</span></td>
试试这个正则表达式:

<td\s.*?>.*?<span\s.*?>(.*?)<\/span><\/td>

期望的输出是什么?7201这个数字我想显示在我的文本框中,但不显示任何输出。也许我在什么地方弄错了。请帮助我。所以,为了确认,你想要一个正则表达式从你问题中的第一个HTML字符串中选择7201?亲爱的朋友,我不完全知道如何使用正则表达式,所以你能给我完整的代码,然后我将进行测试。请为我做我正在等待你的更新。Thanks@browsersumonStackOverflow不是免费的编码服务。首先,试试看。然后查找有关在中使用正则表达式的教程C@browsersumon试试看。这就是我给你的全部信息。
HtmlElementCollection bColl = webBrowser3.Document.GetElementsByTagName("span");
foreach (HtmlElement bEl in bColl)
{
    if (bEl.GetAttribute("style").Contains("font-family:'Segoe UI Bold'"))
        txtlink.Text = bEl.OuterHtml;
}
<td\s.*?>.*?<span\s.*?>(.*?)<\/span><\/td>
<td\s.*?>          # Opening <td> with attributes
.*?                # Optional Data - i.e. Security Code: (Lazy)
<span\s.*?>        # Opening <span> with attributes
(.*?)              # The data you need to Capture - i.e. 7201
<\/span>           # Closing </span>
<\/td>             # Closing </td>