3

私は RegEx が本当に苦手です。以下のコードでは、SH:との間の実際の数値のみが必要です, or end of line.。どうすればこれを達成できますか?

    [TestMethod]
    public void Sandbox()
    {
        var regEx = new Regex(@"SH\:(.*?)(\,|\z)");
        var matches = regEx.Matches("Some Text|SH:0000000000,SH:1111111111");

        foreach (var match in matches)
        {
            Console.Out.WriteLine(match);

             /* Getting this
             SH:0000000000,
             SH:1111111111
             */

             /* Wanting this
             0000000000
             1111111111
             */
        }
    }
4

3 に答える 3