日期:2014-05-17  浏览次数:20457 次

字符串截取
string str = 
"cspz,mkgl,lmgl,yhgl,sjgl,264,263,250,249,248,247,246,245,214,217,166,167,192,193,261,262,259,88,239,76,224,126,222,223,243,194,75,244";
如何得到结果:
cspz,mkgl,lmgl,yhgl,sjgl
264,263,250,249,248,247,246,245,214,217,166,167,192,193,261,262,259,88,239,76,224,126,222,223,243,194,75,244
将其分成两部分,(字符跟数字分开)

------解决方案--------------------
  string str =
"cspz,mkgl,lmgl,yhgl,sjgl,264,263,250,249,248,247,246,245,214,217,166,167,192,193,261,262,259,88,239,76,224,126,222,223,243,194,75,244";
            string arr1 = string.Join(",", str.Split(new char[] { ',' }).Where(x => Regex.IsMatch(x, @"^[a-zA-Z]+$")));
            string arr2 = string.Join(",", str.Split(new char[] { ',' }).Where(x => Regex.IsMatch(x, @"^[0-9]+$")));