[英]Extract Content from <span class=“value ”> </div> Tag C# RegEx
I have some HTML code:我有一些 HTML 代码:
<div class="code">
<span class="title">desc</span>:<span class="value">'Custom text'</span>,
<div class="code">
<span class="title">
</span>
<div>
I need to get the content between <span class="value">...</div>
tags.我需要获取
<span class="value">...</div>
标签之间的内容。 I tried to get - Custom text
.我试图获得 -
Custom text
。 How can I do it with Regex
and C#
?我怎样才能用
Regex
和C#
做到这一点?
您可以在第一组中捕获,例如:
<span .*? class="value".*?>([^<]+)<\/span>
您可以使用以下正则表达式:
<span[^>]*class=\"value\"[^>]*>([^<]*)<\/span>
Add runat="server" to the control of which you want to extract the data in your CS page将 runat="server" 添加到要提取 CS 页面中的数据的控件中
HTML: HTML:
<span class="value" id="test" runat="server">'Custom text'</span>
CS CS
String vl=test.InnerHtml;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.