<tr bgcolor="#E6E6DC"> <td width="16%" align="center" height="20" bgcolor="#E6E6DC"> <font color="#000000"> <b> 估 价:
</b></font> </td> <td width="84%" height="20" bgcolor="#E6E6DC"> <font> RMB 8,000-18,000
</font> </td> </tr>re = new Regex(@"估.*?价.*?\n(?<price>[^\n]*?)</b></font>\s+</td>", RegexOptions.Singleline|RegexOptions.Compiled);
a.Price = re.Match(info).Groups["price"].Value;
以前用的是这个可以取出HTML里的RMB 8,000-18,000
。现在为什么不行了呀?谢谢各位!!
问题解决马上结分。
</b></font> </td> <td width="84%" height="20" bgcolor="#E6E6DC"> <font> RMB 8,000-18,000
</font> </td> </tr>re = new Regex(@"估.*?价.*?\n(?<price>[^\n]*?)</b></font>\s+</td>", RegexOptions.Singleline|RegexOptions.Compiled);
a.Price = re.Match(info).Groups["price"].Value;
以前用的是这个可以取出HTML里的RMB 8,000-18,000
。现在为什么不行了呀?谢谢各位!!
问题解决马上结分。
a.Price = re.Match(info).Groups["price"].Value.Trim();
string resultStr = "";
Match m = Regex.Match(yourStr, @"估\s*价:([\s\S]*?)</tr>", RegexOptions.IgnoreCase);
if (m.Success)
{
resultStr = Regex.Replace(m.Groups[1].Value, @"<[^>]*?>", "").Trim();
}
<td width="16%" align="center" height="20" bgcolor="#E6E6DC">
<font color="#000000"> <b>
估 价:
</b></font> </td>
<td width="84%" height="20" bgcolor="#E6E6DC"> <font>
RMB 8,000-18,000
</font> </td>
</tr>
只有8,000-18,000是变化的。其它的都是不变的。
a.Price = re.Match(yourStr).Groups["price"].Value;
楼上的你能不能写个小例子给我用一下,谢谢你的回答。
string yourStr = richTextBox1.Text;
Regex re = new Regex(@"估\s*?价[\s\S]*?<font>\s*(?<price>[\s\S]*?)\s*</font>\s*</td>", RegexOptions.Compiled);
string resultStr = re.Match(yourStr).Groups["price"].Value;
richTextBox2.Text = resultStr;