求一正则表达式

yrf741676206 2011-11-22 11:29:09

Product Category</div></td>
</tr>
</table>
<table width="100%" align=center >
<tbody >
<tr>
<td class=mm bgcolor="#cccccc">

<TABLE align="center" cellSpacing=0 cellPadding=0 width=99% border=0 bgcolor="#f5f5f5">
<TBODY>
<TR>
<TD vAlign=top style="padding-left:2px;padding-right:2px" >


<table cellspacing=0 cellpadding=0 width="100%" border=0 >
<tbody>

<tr> <td colspan="4" background=images/bg_04.gif border=0></td></tr>
<tr>
<td valign=center height=25 colspan="4" align="left"><img alt=""
src="../image/category_icon.gif" width="11" height="3"><a href=cat.asp?catid=485 target="_blank" ><b><font color="#B713BE">
built-in bulbs series
</font></b></a></td>
</tr>
<tr>
<td colspan="4" background=images/bg_04.gif border=0></td>
</tr>

<tr> <td colspan="4" background=images/bg_04.gif border=0></td></tr>
<tr>
<td valign=center height=25 colspan="4" align="left"><img alt=""
src="../image/category_icon.gif" width="11" height="3"><a href=cat.asp?catid=482 target="_blank" ><b><font color="#B713BE">
led tunnel light
</font></b></a></td>
</tr>
<tr>
<td colspan="4" background=images/bg_04.gif border=0></td>
</tr>

<tr> <td colspan="4" background=images/bg_04.gif border=0></td></tr>
<tr>
<td valign=center height=25 colspan="4" align="left"><img alt=""
src="../image/category_icon.gif" width="11" height="3"><a href=cat.asp?catid=415 target="_blank" ><b><font color="#B713BE">
led outdoor flood light
</font></b></a></td>
</tr>
<tr>
<td colspan="4" background=images/bg_04.gif border=0></td>
</tr>

<tr> <td colspan="4" background=images/bg_04.gif border=0></td></tr>
<tr>
<td valign=center height=25 colspan="4" align="left"><img alt=""
src="../image/category_icon.gif" width="11" height="3"><a href=cat.asp?catid=475 target="_blank" ><b><font color="#B713BE">
led grow light
</font></b></a></td>
</tr>
<tr>
<td colspan="4" background=images/bg_04.gif border=0></td>
</tr>

<tr> <td colspan="4" background=images/bg_04.gif border=0></td></tr>
<tr>
<td valign=center height=25 colspan="4" align="left"><img alt=""
src="../image/category_icon.gif" width="11" height="3"><a href=cat.asp?catid=370 target="_blank" ><b><font color="#B713BE">
led wall washer light
</font></b></a></td>
</tr>
<tr>
<td colspan="4" background=images/bg_04.gif border=0></td>
</tr>

<tr> <td colspan="4" background=images/bg_04.gif border=0></td></tr>
<tr>
<td valign=center height=25 colspan="4" align="left"><img alt=""
src="../image/category_icon.gif" width="11" height="3"><a href=cat.asp?catid=468 target="_blank" ><b><font color="#B713BE">
led street light bulb
</font></b></a></td>
</tr>
<tr>
<td colspan="4" background=images/bg_04.gif border=0></td>
</tr>

<tr> <td colspan="4" background=images/bg_04.gif border=0></td></tr>
<tr>
<td valign=center height=25 colspan="4" align="left"><img alt=""
src="../image/category_icon.gif" width="11" height="3"><a href=cat.asp?catid=467 target="_blank" ><b><font color="#B713BE">
led PLC lamp
</font></b></a></td>
</tr>
<tr>
<td colspan="4" background=images/bg_04.gif border=0></td>
</tr>

<tr> <td colspan="4" background=images/bg_04.gif border=0></td></tr>
<tr>
<td valign=center height=25 colspan="4" align="left"><img alt=""
src="../image/category_icon.gif" width="11" height="3"><a href=cat.asp?catid=461 target="_blank" ><b><font color="#B713BE">
led gas station light
</font></b></a></td>
</tr>
<tr>
<td colspan="4" background=images/bg_04.gif border=0></td>
</tr>

<tr> <td colspan="4" background=images/bg_04.gif border=0></td></tr>
<tr>
<td valign=center height=25 colspan="4" align="left"><img alt=""
src="../image/category_icon.gif" width="11" height="3"><a href=cat.asp?catid=483 target="_blank" ><b><font color="#B713BE">
led cabinet light
</font></b></a></td>
</tr>
<tr>
<td colspan="4" background=images/bg_04.gif border=0></td>
</tr>

<tr> <td colspan="4" background=images/bg_04.gif border=0></td></tr>
<tr>
<td valign=center height=25 colspan="4" align="left"><img alt=""
src="../image/category_icon.gif" width="11" height="3"><a href=cat.asp?catid=479 target="_blank" ><b><font color="#B713BE">
led work light
</font></b></a></td>
</tr>
<tr>
<td colspan="4" background=images/bg_04.gif border=0></td>
</tr>

<tr> <td colspan="4" background=images/bg_04.gif border=0></td></tr>
<tr>
<td valign=center height=25 colspan="4" align="left"><img alt=""
src="../image/category_icon.gif" width="11" height="3"><a href=cat.asp?catid=460 target="_blank" ><b><font color="#B713BE">
led high bay light
</font></b></a></td>
</tr>
<tr>
<td colspan="4" background=images/bg_04.gif border=0></td>
</tr>

<tr> <td colspan="4" background=images/bg_04.gif border=0></td></tr>
<tr>
<td valign=center height=25 colspan="4" align="left"><img alt=""
src="../image/category_icon.gif" width="11" height="3"><a href=cat.asp?catid=428 target="_blank" ><b><font color="#B713BE">
led ribbon ( Flexible strips )
</font></b></a></td>
</tr>
<tr>
<td colspan="4" background=images/bg_04.gif border=0></td>
</tr>

<tr> <td colspan="4" background=images/bg_04.gif border=0></td></tr>
<tr>
<td valign=center height=25 colspan="4" align="left"><img alt=""
src="../image/category_icon.gif" width="11" height="3"><a href=cat.asp?catid=465 target="_blank" ><b><font color="#B713BE">
led pool light
</font></b></a></td>
</tr>
<tr>
<td colspan="4" background=images/bg_04.gif border=0></td>
</tr>

<tr> <td colspan="4" background=images/bg_04.gif border=0></td></tr>
<tr>
<td valign=center height=25 colspan="4" align="left"><img alt=""
src="../image/category_icon.gif" width="11" height="3"><a href=cat.asp?catid=459 target="_blank" ><b><font color="#B713BE">
led strip light
</font></b></a></td>
</tr>
<tr>
<td colspan="4" background=images/bg_04.gif border=0></td>
</tr>

<tr> <td colspan="4" background=images/bg_04.gif border=0></td></tr>
<tr>
<td valign=center height=25 colspan="4" align="left"><img alt=""
src="../image/category_icon.gif" width="11" height="3"><a href=cat.asp?catid=462 target="_blank" ><b><font color="#B713BE">
led module
</font></b></a></td>
</tr>
<tr>
<td colspan="4" background=images/bg_04.gif border=0></td>
</tr>

<tr> <td colspan="4" background=images/bg_04.gif border=0></td></tr>
<tr>
<td valign=center height=25 colspan="4" align="left"><img alt=""
src="../image/category_icon.gif" width="11" height="3"><a href=cat.asp?catid=411 target="_blank" ><b><font color="#B713BE">
led light bulb
</font></b></a></td>
</tr>
<tr>
<td colspan="4" background=images/bg_04.gif border=0></td>
</tr>

<tr> <td colspan="4" background=images/bg_04.gif border=0></td></tr>
<tr>
<td valign=center height=25 colspan="4" align="left"><img alt=""
src="../image/category_icon.gif" width="11" height="3"><a href=cat.asp?catid=412 target="_blank" ><b><font color="#B713BE">
led spot light
</font></b></a></td>
</tr>
<tr>
<td colspan="4" background=images/bg_04.gif border=0></td>
</tr>
</tbody>
</table>
</TD>
</TR>
</TBODY>
</TABLE>
</td>
</tr>
</tbody>
</table> </td>
</tr>
<tr>
<td width="212" height="166" valign="top" bgcolor="#eeeeee"><table width="100%" border="0" cellspacing="0" cellpadding="0" >
<tr>
<td height="4"></td>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" background="image/images/panhang_06.gif"><td width="209" height="31" border="0"><div align="center" class="STYLE3">EL Products Recommen
...全文
89 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复

string tempStr = File.ReadAllText(@"C:\Documents and Settings\Administrator\桌面\Test.txt", Encoding.GetEncoding("GB2312"));
string pattern = @"(?im)<a[^>]href=['""]?([^'""\s]+)[^>]*>\s*(<[^>]+>\s*)*([^<]+)\s*</font></b></a>";
MatchCollection mc = Regex.Matches(tempStr, pattern, RegexOptions.IgnoreCase | RegexOptions.Multiline);
foreach (Match m in mc)
{
//循环输出
string href = m.Groups[1].Value;
string text = m.Groups[3].Value;

}
yrf741676206 2011-11-22
  • 打赏
  • 举报
回复
楼上两位 不行啊 得不到值
wushuai1346 2011-11-22
  • 打赏
  • 举报
回复
试试这个吧
@"href=(?'AAA'\S*?) [^>]*?><b><font[^>]*?>(?'BBB'[\s\S]*?)</font>"

记得把RegexOptions.IgnoreCase加上
PandaIT 2011-11-22
  • 打赏
  • 举报
回复
try



(?i)<a href=(?<url>.*?) target="_blank" ><b><font color="#B713BE">(?<text>.*?)</font></b></a>

yrf741676206 2011-11-22
  • 打赏
  • 举报
回复
大神些 人呢
yrf741676206 2011-11-22
  • 打赏
  • 举报
回复
大神些 人呢
yrf741676206 2011-11-22
  • 打赏
  • 举报
回复
从以上代码获取
比如:<a href=cat.asp?catid=485 target="_blank" ><b><font color="#B713BE">
built-in bulbs series
</font>
中的cat.asp?catid=485 和built-in bulbs series
yrf741676206 2011-11-22
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 return_false 的回复:]
C# code


string tempStr = File.ReadAllText(@"C:\Documents and Settings\Administrator\桌面\Test.txt", Encoding.GetEncoding("GB2312"));
string pattern = @"(?im)<a[^>]href=['""]?([^'""\s]……
[/Quote]
大神啊 感谢了

110,502

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧