Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/16.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 替换HTML表单元素?_Regex_Vb.net_Replace - Fatal编程技术网

Regex 替换HTML表单元素?

Regex 替换HTML表单元素?,regex,vb.net,replace,Regex,Vb.net,Replace,我有以下HTML代码: <HTML> <HEAD> <TITLE></TITLE> </HEAD> <BODY> <form action="http://www.aweber.com/scripts/addlead.pl" method="post"> <input id="email" class="text" type="text" size="20" value="Enter your bes

我有以下HTML代码:

<HTML>
<HEAD>
<TITLE></TITLE>

</HEAD>

<BODY>

<form action="http://www.aweber.com/scripts/addlead.pl" method="post">
<input id="email" class="text" type="text" size="20" value="Enter your best email" name="email" onblur="if (this.value == '') {this.value = 'Enter your best email';}" onfocus="if (this.value == 'Enter your best email') {this.value = '';}" />
<input type="hidden" name="meta_web_form_id" value="">
<input type="hidden" name="meta_split_id" value="">
<input type="hidden" name="listname" value="">
<input type="hidden" name="redirect" value="">
<input type="hidden" name="meta_adtracking" value="">
<input type="hidden" name="meta_message" value="1">
<input type="hidden" name="meta_required" value="email">
<input type="hidden" name="meta_tooltip" value="">
<div style="padding-top:5px;">
<center><input class="button1" id="submit" type="image" src="red_getwaitinglist.png" name="submit" value="Get Instant Access"/></center>
</div>
</form>

</BODY>
</HTML>

我用这个函数替换使用正则表达式的元素:

Function StripTags(ByVal html As String, ByVal replace As String) As String
    Return Regex.Replace(html, "<form.+?</form>", replace)
End Function
函数StripTags(ByVal html作为字符串,ByVal替换为字符串)作为字符串

返回Regex.Replace(html,附加RegexOption
Singleline
。没有这个
将不匹配换行符

Return Regex.Replace(html, "<form.+?</form>", replace, RegexOptions.Singleline)

Return Regex.Replace(html),“您应该使用HtmlAgilityPack。您应该使用HtmlAgilityPack,因为在html中使用正则表达式会遇到非常严重的问题。请不要这样做。我已经编辑了您的标题。请参阅,”,其中一致意见是“不,他们不应该”.谢谢你们,我只是看看HtmlAgilityPack,我想你们给我指明了正确的方向。我以前从未听说过,所以谢谢你们两位。