我无法从字符串中捕获值。我只想要我不想捕获的数字T
or :
。这个失败的测试说明:
[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:"
}