我真的很可怕的RegEx,在下面的代碼中,我只想要SH:
和, or end of line.
之間的實際數字我該如何實現這一目標?正則表達式在C#中,獲取無標準的值
[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
*/
}
}
此模式有效:'SH:(\ d +),*' –