I am having trouble capturing a value from a string. I only want the number I don't want to capture the T
or :
. This failing test explains:
[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:"
}