- A+
所属分类:.NET技术
比如要拆分“呵呵呵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()); }