首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

html-正则表达式求解

2011-12-10 
html--正则表达式求解html文件中的其中一段原码tablewidth 552 border 0 align center cellpadd

html--正则表达式求解
html文件中的其中一段原码

<table   width= "552 "   border= "0 "   align= "center "   cellpadding= "0 "   cellspacing= "0 ">
                                <tr>
                                    <td   width= "20 "   bgcolor= "#FFFFFF "> <strong> <font   style= "font-size:12px "> <img   src= "images/TEAM.gif "   width= "16 "   height= "16 ">   </font> </strong> </td>
                                    <td   width= "529 "   height= "20 "   bgcolor= "#FFFFFF "> <strong> <font   style= "font-size:12px "   color= "#0000ff "> Esales   系统提示 </font> </strong> </td>
  </tr>
                            </table>
    <p> &nbsp; </p>
    <table   width= "90% "   border= "0 "   cellspacing= "1 "   cellpadding= "3 "   bgcolor= "#6394bd "   align= "center ">
  <tr>  
  <td   bgcolor= "#dee7ef "> 错误信息提示 </td>
  </tr>
<tr>  
<td   align= "center "   bgcolor= "#FFFFFF "   style= 'line-height:150%; '>
<br>
<br>
您的库存不足支付本次销售额!(如您的上级代理商已经划拨金额到您的帐号,请重新登陆!) <br>
<br> <br> <a   href= "# "   onclick= "history.go(-1) "> [   点击这里返回上一页   ] </a>

<br>
<br>
  </td>
</tr>
</table> <p> &nbsp; </p>
<p> &nbsp; </p>
</td>
                        </tr>
                        <tr>
                            <td> <img   src= "images/ge02.jpg "   width= "565 "   height= "6 "> </td>
                        </tr>
                    </table>


需要用正则找出的内容

您的库存不足支付本次销售额!(如您的上级代理商已经划拨金额到您的帐号,请重新登陆!)

谢谢


[解决办法]
好像不行


My-Blog地址1:http://www.cnblogs.com/nyzfl
My-Blog地址2: http://blog.csdn.net/nyzfl
[解决办法]
确实比较困难,自认为实力不够解决LZ的问题
[解决办法]
string sourse;
using (StreamReader st = new StreamReader(@ "e:\test.txt ",Encoding.Default))


{
sourse = st.ReadToEnd();
}
Regex re = new Regex(@ "错误信息提示(.*?\s*)* <br> \s*(? <message> [\u4e00-\u9fa5][^ <]*) ");
Match rem = re.Match(sourse);
MessageBox.Show(sourse);

再试下

MessageBox.Show(rem.Groups[ "message "].ToString());
[解决办法]
断了一天的网-_-#

最上面那个

string yourStr = ...............;
string result = " ";
Match m = Regex.Match(yourStr, @ "错误信息提示(? <content> [\s\S]*?)\[\s*点击这里返回上一页 ");
if (m.Success)
{
result = Regex.Replace(m.Groups[ "content "].Value, @ "\s* <[^> ]*> \s* ", " ");
}


上面这个取value的,是name固定,还是只要input的就取,前者

string yourStr = .............;
string result = " ";
Match m = Regex.Match(yourStr, @ " <input[^> ]*name= " "UsersecretID " "\s*value=([ ' " "])?(? <value> [^ ' " "> ]*)\1[^> ]*> ");
if (m.Success)
{
result = m.Groups[ "value "].Value;
}

后者

string yourStr = ..................;
string result = " ";
Match m = Regex.Match(yourStr, @ " <input[^> ]*value=([ ' " "])?(? <value> [^ ' " "> ]*)\1[^> ]*> ");
if (m.Success)
{
result = m.Groups[ "value "].Value;
}

热点排行
Bad Request.