1

C# の初心者です.. 助けが必要です.. これを C# に変換しようとしていますが、C# の preg_match_all に相当するものがわかりません..いくつかの本を読んでいますが、わかりません..:'(

$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];
    }**
4

2 に答える 2

1

静的メソッドを使用

public static Match Match(
    string input,
    string pattern,
    RegexOptions options
)

この関数の戻り値:

System.Text.RegularExpressions.Match 一致に関する情報を含むオブジェクト。

詳細については、こちらを参照してください

于 2013-10-21T06:43:08.363 に答える