开发者

Regex to match the pattern [-][number][number]

hi i need to match the following string in c#

for example

-34

-67

-23

-46

-00

i would loop over开发者_如何学Go the string and check each char but thats messy and i have no idea about regex so was hoping for some help.

thanks


The following regex should work

@"-\d\d"


-(\d\d) is the pattern

Regex rx = new Regex(@"-(\d\d)");
var matches = rx.Matches(str);
foreach (var match in matches)
    Console.WriteLine(match.Groups[1].Value);


I think -\d\d should be able to do it

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜