日期:2014-05-17  浏览次数:20494 次

求一算法~~~~
已知字符串 “a1b22c3333”
如何取出相对应数字的方法
求简单点的方法
------最佳解决方案--------------------

using System.Text.RegularExpressions;


            string str = "a1b22c3333";
            foreach (Match match in Regex.Matches(str, @"\d+"))
                Console.WriteLine(match.Value);


------其他解决方案--------------------
string str = "a1b22c3333";
            var ary = Regex.Matches(str, @"([a-zA-Z]+)(\d+)").Cast<Match>().Select(t => new { eng = t.Groups[1].Value, shuzi = t.Groups[2].Value }).ToArray();
            foreach (var tt in ary)
                Console.WriteLine(tt.eng + ":" + tt.shuzi);
           
------其他解决方案--------------------
引用:
C# code?123456using System.Text.RegularExpressions;              string str = "a1b22c3333";            foreach (Match match in Regex.Matches(str, @"\d+"))                Console.WriteLine……
+1
------其他解决方案--------------------
引用:
C# code?123456using System.Text.RegularExpressions;              string str = "a1b22c3333";            foreach (Match match in Regex.Matches(str, @"\d+"))                Console.WriteLine……


怎么取前面的英文字母然后对应呢?
------其他解决方案--------------------
引用:
引用:C# code?123456using System.Text.RegularExpressions;              string str = "a1b22c3333";            foreach (Match match in Regex.Matches(str, @"\d+"))             ……

就不能一次问完……

            string str = "a1b22c3333";
            foreach (Match match in Regex.Matches(str, @"([a-zA-Z]+)(\d+)"))
                Console.WriteLine("字母:" + match.Groups[1].Value + ",数字:" + match.Groups[2].Value);


------其他解决方案--------------------