首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

求一算法~该怎么处理

2012-12-21 
求一算法~~~~已知字符串 “a1b22c3333”如何取出相对应数字的方法求简单点的方法[最优解释]using System.Tex

求一算法~~~~
已知字符串 “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);


[其他解释]


结贴给分

热点排行