<td style="background:url(img/tel_mid.gif) bottom repeat-x; border:0px; padding:0px; padding-top:17px; font-size:16px; font-weight:bolder">85555158, 15052524534, 13004334564</td><td style="padding:0px; border:0px" valign="bottom"><img src="img/tel_right.gif" width="10" height="41" /></td>
我使用正则(?is)(?<=font-weight:bolder">).*?(?=</td>)在Regex Tester中测试是能取得"85555158, 15052524534, 13004334564"可我在实际使用中
Match m = Regex.Match(content, @"(?is)(?<=font-weight:bolder"">).*?(?=</td>)");
ii = m.Value; //这里只能取得 请问为何啊
我使用正则(?is)(?<=font-weight:bolder">).*?(?=</td>)在Regex Tester中测试是能取得"85555158, 15052524534, 13004334564"可我在实际使用中
Match m = Regex.Match(content, @"(?is)(?<=font-weight:bolder"">).*?(?=</td>)");
ii = m.Value; //这里只能取得 请问为何啊
邮箱:[email protected]
谢谢!
string content = @"<td style=""background:url(img/tel_mid.gif) bottom repeat-x; border:0px; padding:0px; padding-top:17px; font-size:16px; font-weight:bolder"">85555158, 15052524534, 13004334564 </td> <td style=""padding:0px; border:0px"" valign=""bottom""> <img src=""img/tel_right.gif"" width=""10"" height=""41"" /> </td> ";
Match m = Regex.Match(content, @"(?is)(?<=font-weight:bolder"">).*?(?= </td>)");
if (m.Success)
{
Response.Write(m.Value);
}
string test = "<td style=\"background:url(img/tel_mid.gif) bottom repeat-x; border:0px; padding:0px; padding-top:17px; font-size:16px; font-weight:bolder\">85555158, 15052524534, 13004334564 </td> <td style=\"padding:0px; border:0px\" valign=\"bottom\"> <img src=\"img/tel_right.gif\" width=\"10\" height=\"41\" /> </td> ";
Match m = Regex.Match(test, @"(?is)(?<=font-weight:bolder"">).*?(?=</td>)");
if (m.Success)
{
richTextBox2.Text += m.Value + "\n";
}
/*-------输出-------
85555158, 15052524534, 13004334564
*/但是正则建议写成如下形式,提高效率
@"(?is)(?<=font-weight:bolder"">)[^<]*(?=</td>)"