こんにちは、以下のタグから結果を取得しようとしています。達成する必要があるのは、タグの最初の一致、次に 5 番目の一致、次に 9 番目の一致を取得することです。したがって、私の結果は次のようになります
私が使用している正規表現は
<td class="stat">(.*?)<\/td>
私が使用しているコードは
private static ObservableCollection<Top> top = new ObservableCollection<Top>();
public void twit_topusers_DownloadStringCompleted(Object sender, DownloadStringCompletedEventArgs e)
{
string str;
// Size the control to fill the form with a margin
str = (string)e.Result;
Regex r = new Regex("<td class=\"stat\">(.*?)</td>");
// Find a single match in the string.
Match m = r.Match(str);
while (m.Success)
{
testMatch = "";
//
testMatch += System.Text.RegularExpressions.Regex.Unescape(m.Groups[0].ToString()).Trim();
top.Add(new Top(testMatch));
m = m.NextMatch();
}
listBox.ItemsSource = top;
}
}
タグは
<td class="stat">14307149</td>//FIRST
<td class="stat">679761</td>
<td class="stat">3508</td>
<td class="stat">62 months ago</td>
<td class="stat">1430700</td>//FIFTH
<td class="stat">679761</td>
<td class="stat">3508</td>
<td class="stat">72 months ago</td>
<td class="stat">1430600</td>//NINTH
<td class="stat">679761</td>
<td class="stat">3508</td>
<td class="stat">82 months ago</td>
しかし、私が得ている結果は
マッチ 1 14307149
マッチ 2 679761
マッチ 3 3508
マッチ 4 62ヶ月前
マッチ 5 1430700
マッチ 6 679761
マッチ 7 3508
一致 8 72 ヶ月前
マッチ 9 14307149
マッチ 10 679761
マッチ 11 3508
マッチ 12 62 ヶ月前
私が必要とする結果は
マッチ 1 14307149
マッチ 2 1430700
マッチ 3 1430600
これで私を助けてもらえますか?