文字列から名前付きグループにテキストを引き出す正規表現パターンに苦労しています。
(やや恣意的な) 例は、私が達成しようとしていることを最もよく説明しています。
string input =
"Mary Anne has been to 949 bingo games. The last was on Tue 24/04/2012. She won with the Numbers: 4, 6, 11, 16, 19, 27, 45";
string pattern =
@"(?<Person>\w+?) has been to (?<NumberOfGames>\d+?) bingo games. The last was on (?<Day>...?) (?<Date>...?). She won with the Numbers: (?<Numbers>...?)";
Regex regex = new Regex(pattern);
var match = regex.Match(input);
string person = match.Groups["Person"].Value;
string noOfGames = match.Groups["NumberOfGames"].Value;
string day = match.Groups["Day"].Value;
string date = match.Groups["Date"].Value;
string numbers = match.Groups["Numbers"].Value;
正規表現パターンを機能させることができないようですが、上記で十分に説明されていると思います。基本的に、人の名前、ゲームの数などを取得する必要があります。
誰でもこれを解決し、彼らが解決した実際の正規表現パターンを説明できますか?