比如要拆分“呵呵呵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());
        }

 

相关文章:

  • 2022-01-01
  • 2022-12-23
  • 2021-07-18
  • 2021-06-18
  • 2021-12-04
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案