采集数据 正则表达式求教
以下源文件片段我要通过判断01 03 来获取数值15,请问正则表达式怎么写呀?
<td>01 03</td>
<td>14150 / 14075</td>
<td>18.280%</td>
<td>4.4695</td>
<td>56</td>
<td>5</td>
<td>15</td>
<td>3.36</td>
<td>2.727</td>
<td>-1.818</td>
//string zuhe 代表的就是片段中的01 03//需要返回结果就是片段中的15private string _采集(string zuhe,string url) { System.Net.WebClient wc = new System.Net.WebClient(); string data = Encoding.UTF8.GetString(wc.DownloadData(string.Format(url))); // 求教中间部分的代码 return data; }
string str = File.ReadAllText(@"E:\1.txt", Encoding.GetEncoding("gb2312")); Regex reg = new Regex(@"(?is)<tr>\s*<td>(.*?)</td>(?:\s*<td>.*?</td>){5}\s*<td>(.*?)</td>.*?</tr>"); foreach (Match m in reg.Matches(str)) Console.WriteLine("{0}==={1}", m.Groups[1].Value, m.Groups[2].Value);/*01 02===201 03===602 03===001 04===4*/