HTML源C#Regex.Matches HTML如php preg_match_all
<form>
<input type="text" name="a" value="a1fa4" type="hidden"/>
<input type="text" name="b" value="b1fa9" type="hidden"/>
<input type="text" name="c" value="c1fd2" type="hidden"/>
<input type="text" name="d" value="d1fx1" type="hidden"/>
</form>
PHP源
<?php
preg_match_all('/<input name="(.*?)" value="(.*?)" type="hidden"\/>/i', $form, $input);
$var = array();
for($i=0;$i<count($input[1]);$i++){
$var[$input[1][$i]] = $input[2][$i];
}
?>
C#源
Match match = Regex.Match(html, "<input name=\"(.*?)\" value=\"(.*?)\" type=\"hidden\"/>", RegexOptions.IgnoreCase);
while (match.Success)
{
System.Console.WriteLine(" {0} {1} ", match.Value, match.Index);
}
PHP的代碼工作輸入,但C#代碼不工作。我怎樣才能修復C#代碼? 謝謝!
[just code](http://stuck.include-once.org/#help5)的請求通常是無關緊要的。主要網站意圖是編碼方法,而不是現成的解決方案,本身也不是[tutoring](http://stuck.include-once.org/#help6)。 – hakre