首页 新闻 会员 周边

用c#,分类字符并显示

0
[待解决问题]

用c# 输入一行字符,把其中的字母,数字分类出来,并把每一类分别显示,用form窗体,button和textbox实现

c#
915545924的主页 915545924 | 菜鸟二级 | 园豆:204
提问于:2013-05-16 13:30
< >
分享
所有回答(1)
3
 public void test()
        {
            Regex numR = new Regex(@"\d");
            Regex strR = new Regex(@"\D");

            string testStr = "asdfasdf8asdfasdf9adsfasd9";

            var temp2 = strR.Matches(testStr);

            string resultNum = "";
            string resultStr = "";

            foreach (Match item in numR.Matches(testStr))
            {
                resultNum += item.Value;
            }

            foreach (Match item in strR.Matches(testStr))
            {
                resultStr += item.Value;
            }

            Response.Write(resultNum + "|" + resultStr);
        }
Eric.luo | 园豆:853 (小虾三级) | 2013-05-16 14:13
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册