文字列から値を取得するのに問題があります。T
またはをキャプチャしたくない番号だけが必要です:
。この失敗したテストは説明します:
[TestMethod]
public void RegExTest()
{
var rex = new Regex("^T([0-9]+):"); //as far as I understand, the () denote the capture group
var match = rex.Match("T12:abc");
Assert.IsTrue(match.Success);
Assert.IsTrue(match.Groups[0].Success);
Assert.AreEqual("12", match.Groups[0].Captures[0]); //fails, actual is "T12:"
}