日期:2014-05-17 浏览次数:20497 次
string tempStr = File.ReadAllText(@"C:\Documents and Settings\Administrator\桌面\Test.txt", Encoding.GetEncoding("GB2312"));//读取txt
string pattern = @"(?i)(<tr[^>]*?>(<td[^>]*?>[^<]*?</td>){2})((?!</tr>).)*?(<td[^>]*?>[^<]*?%[^<]*?</td>).*?(</tr>)";
string[] tempStr_list = Regex.Matches(tempStr, pattern).Cast<Match>().Select(a=>Regex.Replace(a.Value,pattern,"$1$4$5")).ToArray();
/*
[0] "<tr><td height=27 align=center>现货铂金</td><td height=18 align=center>289.26</td><td height=18 align=center>-0.36%</td></tr>" string
[1] "<tr><td height=27 align=center>现货钯金</td><td height=18 align=center>117.83</td><td height=18 align=center>-0.46%</td></tr>" string
[2] "<tr><td height=27 align=center>现货白银</td><td height=18 align=center>5482</td><td height=18 align=center>-0.38%</td></tr>" string
*/