C# を使用して次のパターンに一致させようとしていますが、一致するものが見つかりません
正規表現
^([[a-z][A-Z]]*):([[a-z][A-Z][0-9],]*)$
サンプル文字列
Student:Tom,Jerry
同じことがルビーでも機能しますが(Rubularを使用して検証しました)。これがc#で機能しない理由は何ですか?
コードブロック
public static KeyValuePair<string, IList<string>> Parse(string s)
{
var pattern = new Regex(@"(\w*):([\w\d,]*)");
var matches = pattern.Matches(s);
if (matches.Count == 2)
{
return new KeyValuePair<string, IList<string>>(matches[0].Value, matches[1].Value.Split(','));
}
throw new System.FormatException();
}