日期:2014-05-18 浏览次数:20733 次
string test = @"\n\t\t\t\t@\n\t\t\t\t1|\n\t\t\t\t完成\n\t\t\t\t@\n\t\t\t\t2|\n\t\t\t\t末完成\n\t\t\t\t@\n\t\t\t\t3|\n\t\t\t\t提交中"; string pattern = @"(?i)(\d+)\|.*?([\u4e00-\u9fa5]+)"; foreach (Match m in Regex.Matches(test, pattern)) { string code = m.Groups[1].Value;//1 string name = m.Groups[2].Value;//完成 }
------解决方案--------------------
string s = "\n\t\t\t\t@\n\t\t\t\t1|\n\t\t\t\t完成\n\t\t\t\t@\n\t\t\t\t2|\n\t\t\t\t末完成\n\t\t\t\t@\n\t\t\t\t3|\n\t\t\t\t提交中"; MatchCollection matches = Regex.Matches(s, @"(\d+)\|\n\t+(\S+)"); foreach (Match match in matches) { Response.Write(match.Groups[1].Value + ":" + match.Groups[2].Value + "<br/>"); }