剛剛新到C#..我需要一些幫助..即時嘗試將此轉換爲C#,但不知道什麼是相當於preg_match_all在C#..一直在讀一些書,但我沒有得到它..:'(C#版本的preg_match
$pattern =
'@' .
'<td>\s*' .
'(?P<no>\d+)\.\s*' .
'</td>\s*' .
'<td>\s*' .
'<a class="LN" href="[^"]*+" onclick="[^"]*+">\s*+' .
'<b>(?P<name>[^<]*+)</b>\s*+' .
'</a>.*\s*' .
'</td>\s*+' .
'<td align="center">[^<]*+</td>\s*+' .
'<td>\s*+' .
'(?P<locations>(?:<a href="[^"]*+">[^<]*+</a><br />\s*+)++)' .
'</td>' .
'@'
;
$results = array();
preg_match_all($pattern, $contents, $matches, PREG_SET_ORDER);
foreach ($matches as $i => $match) {
preg_match_all('@<a href="[^"]*+">([^<]*+)</a>@', $match['locations'], $locations);
$results[$i]['no'] = $match['no'];
$results[$i]['name'] = $match['name'];
$results[$i]['locations'] = $locations[1];
}**
它看起來像它的使用正則表達式來嘗試分析一些HTML - 這將是更好地使用像一個合適的工具[HTML敏捷包](http://htmlagilitypack.codeplex.com/)。 –
WebClient怎麼樣? – Cindy93