比如要拆分“呵呵呵90909086676喝喝999”,下麵當type=0返回的是中文字元串“呵呵呵,喝喝”,type=1返回的是數字字元串“90909086676,999”, private string GetStrings(string str,int type=0) { IList<strin ...
比如要拆分“呵呵呵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()); }