日期:2014-05-17 浏览次数:20544 次
string tempStr = File.ReadAllText(@"C:\Users\M\Desktop\Test.txt", Encoding.GetEncoding("GB2312"));
string pattern = @"(?i)<properties>[\s\S]*?<t1>([^<\s]+)<\\/t1>[\s\S]*?<t2>([^<\s]+)<\\/t2>[\s\S]*?<t3>([^<\s]+)<\\/t3>[\s\S]*?";
var result = Regex.Matches(tempStr, pattern).Cast<Match>().Select(a => new {
t1=a.Groups[1].Value,
t2 = a.Groups[2].Value,
t3 = a.Groups[3].Value
});
/*
* + [0] { t1 = "aaaaaaaa", t2 = "bbbbbbbb", t3 = "cccccccc" } <Anonymous Type>
+ [1] { t1 = "dddddd", t2 = "eeeeee", t3 = "ffffff" } <Anonymous Type>
+ [2] { t1 = "gggggg", t2 = "hhhhhh", t3 = "iiiiii" } <Anonymous Type>
*/