VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > temp > C#教程 >
  • C#拆分中文和数字字符串

比如要拆分“呵呵呵90909086676喝喝999”,下面当type=0返回的是中文字符串“呵呵呵,喝喝”,type=1返回的是数字字符串“90909086676,999”,

复制代码
 private string GetStrings(string str,int type=0)
        {
            IList<string> strList = new List<string>();
            MatchCollection ms;
            if (type == 0)
            {
                ms = Regex.Matches(str, @"\D+"); 
            }
            else
            {
                ms = Regex.Matches(str, @"\d+");
            }
          
            foreach (Match m in ms)
            {
                strList.Add(m.Value);
            }
            return string.Join("",strList.ToArray());
        }
复制代码

 

量变会引起质变。

文章出处:https://www.cnblogs.com/bibi-feiniaoyuan/p/13395146.html



相关教程