日期:2014-05-17 浏览次数:20606 次
string tempStr = File.ReadAllText(@"C:\Documents and Settings\Administrator\桌面\Test.txt", Encoding.GetEncoding("GB2312"));//读取txt
string pattern = @"(?i)<span[^>]*?class=(['""]?)tit\1[^>]*?>[\s\S]*?<a[^>]*?href=(['""]?)[^'""]*?\?Hid=(?<Hid>\d+)[^'""]*?\2[^>]*?>(?<a_text>[^<>]+?)</a>";
pattern += @"[\s\S]*?<span[^>]*?class=(['""]?)tit\3[^>]*?>(?<value>[\s\S]*?)</li>";
foreach (Match m in Regex.Matches(tempStr, pattern))
{
//循环输出
string v1 = m.Groups["Hid"].Value;//160
string v2 = m.Groups["a_text"].Value;//李宁
string v3 = m.Groups["value"].Value;//主讲人介绍:</span>北京市学院路中学数学教师,北京市海淀区数学学科区级骨干教师。在北京市教师基本功展示活动中获二等奖。教学风格亲切,深受学生喜爱。
}