日期:2014-05-18  浏览次数:20805 次

正则表达式?
字符串内容有可能为:   mystat( 'nl ',345)   或   mystat( 'sta ',33)
现要用正则表达式取出其中的数字部分,怎么取?
用IndexOf的方法就不要说了

------解决方案--------------------
Regex reg =new Regex(@ "\d+ ");
string str = "mystat( 'nl ',345) ";
MatchCollection mc = reg.Matches(str);
for (int i = 0; i < mc.Count; i++)
Console.WriteLine(mc[i].Value);
------解决方案--------------------
string a= " "; //你的字符串
Regex RegexNumber = new Regex(@ "(? <=,)\d+(?=\)) ");
string number = RegexNumber.Match(a).ToString();//number就是结果数字