日期:2014-05-17 浏览次数:20483 次
string source = "baidu_{0}_{1}"; Regex reg = new Regex(@"(?is){\d*}"); MatchCollection mc = reg.Matches(source); MessageBox.Show(mc.Count.ToString());
------解决方案--------------------
string str = "baidu_{0}_{1}"; Regex rgx = new Regex(@"{\d+}"); Console.WriteLine(rgx.Matches(str).Count);
------解决方案--------------------
Regex.Match(yourstr,"{[^{}]*?}").Count