string s = "ffdsaf2121fdsafd";
字符串不确定,想用正则表达式快速行到2121中间这段数字有什么方法

解决方案 »

  1.   

    string s="";
        foreach(Match m in Regex.Matches(s,@"\d+"))
        {
            Console.WriteLine(m.Value);
        }
      

  2.   

    using System.Text.RegularExpressions; ......... string str1 = "ffdsaf2121fdsafd";
    string str2 = @"\d+"; //正则表达式,匹配数字串的 MatchCollection Matches = Regex.Matches(str1, str2); foreach (Match NextMatch in Matches) 

      string num = NextMatch.Value; 
    }