php 正则表达式
把下面类似代码中 域名都匹配出来 比如:www.i-tech.com.au
<table border="0" width="100%" cellpadding="5" cellspacing="0"><tr><td colspan="2"><table border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td><font size="2" face="Verdana,Arial" color="#000000"><b>Search Results</b></font></td><td width="150" align="right"><div class="addthis_default_style"><span class="addthis_separator"><font size=1>share</font></span> <a class="addthis_button_email"></a> <a class="addthis_button_facebook"></a> <a class="addthis_button_google"></a> <a class="addthis_button_twitter"></a></div><script type="text/javascript" src="/addthis_widget.js#username=xa-4bcc31a81caa95eb"></script></td></tr></table></td></tr> <tr><td colspan="2"><tr><td valign=top width="70"> <b>Price</b></td><td valign=top align="left"><b>Description</b></td></tr><tr valign="top"><td align="left"><a title="I-Tech: Click to see item" href="/cgi-bin/redirect.cgi?name=I-Tech&linkid=2&newurl=http%3A%2F%2Fwww.i-tech.com.au%2Fproducts%2F526_NEW_ARRIVAL.aspx&query=Enzatec%20SP308&uca=64-0-0&kwi=&rpos=1" >$27.00</a><br></td><td valign="bottom">Enzatec SP308 2.0 Speaker 2x2.5W 3.5mm Plug Retractable Cable Rechargeable ...<br><font color="#808080"><a title="Click to visit the I-Tech web site" href="/cgi-bin/redirect.cgi?name=I-Tech&linkid=1&newurl=http%3A%2F%2Fwww.i-tech.com.au&query=Enzatec%20SP308&uca=64-0-0&kwi=&rpos=1" style="text-decoration:none" onMouseOver="this.style.textDecoration='underline'" onMouseOut="this.style.textDecoration='none'">I-Tech</a> (NSW) | www.i-tech.com.au | updated: 16-05-2012</td></tr><tr valign="top"><td align="left"><a title="VTech Industries: Click to see item" href="/cgi-bin/redirect.cgi?name=VTech%20Industries&linkid=2&newurl=http%3A%2F%2Fwww.vtechindustries.com.au%2Fspeaker-systems%2Fenzatec&query=Enzatec%20SP308&uca=217-0-0&kwi=&rpos=3" >$27.94</a><br></td><td valign="bottom">Enzatec SP308 2.0 Speaker 2x2.5W 3.5mm Plug Retractable Cable Rechargeable ...<br><font color="#808080"><a title="Click to visit the VTech Industries web site" href="/cgi-bin/redirect.cgi?name=VTech%20Industries&linkid=1&newurl=http%3A%2F%2Fwww.vtechindustries.com.au&query=Enzatec%20SP308&uca=217-0-0&kwi=&rpos=3" style="text-decoration:none" onMouseOver="this.style.textDecoration='underline'" onMouseOut="this.style.textDecoration='none'">VTech Industries</a> (WA) | www.vtechindustries.com.au | updated: 17-05-2012</td></tr><tr valign="top"><td align="left"><a title="Megaware Computers: Click to see item" href="/cgi-bin/redirect.cgi?name=Megaware%20Computers&linkid=2&newurl=http%3A%2F%2Fwww.megaware.com.au%2Findex.php%3Fmain_page%3Dindex%26cPath%3D1497%26sort%3D2a%26page%3D10&query=Enzatec%20SP308&uca=564-0-0&kwi=&rpos=5" >$29.00</a><br></td><td valign="bottom">Enzatec SP308 2.0 Speaker 2x2.5W 3.5mm Plug Retractable Cable Rechargeable ...<br><font color="#808080"><a title="Click to visit the Megaware Computers web site" href="/cgi-bin/redirect.cgi?name=Megaware%20Computers&linkid=1&newurl=http%3A%2F%2Fwww.megaware.com.au&query=Enzatec%20SP308&uca=564-0-0&kwi=&rpos=5" style="text-decoration:none" onMouseOver="this.style.textDecoration='underline'" onMouseOut="this.style.textDecoration='none'">Megaware Computers</a> (NSW) | www.megaware.com.au | updated: 16-05-2012</td></tr><tr valign="top"><td align="left"><a title="D&D Computer Technology: Click to see item" href="/cgi-bin/redirect.cgi?name=D%26D%20Computer%20Technology&linkid=2&newurl=http%3A%2F%2Fwww.ddcomputer.com.au%2Fparts_SPK_Speakers.html&query=Enzatec%20SP308&uca=240-0-0&kwi=&rpos=7" >$33.00</a><br></td><td valign="bottom">Enzatec SP308 2.0 Speaker 2x2.5W 3.5mm Plug Retractable Cable Rechargeable ...<br><font color="#808080"><a title="Click to visit the D&D Computer Technology web site" href="/cgi-bin/redirect.cgi?name=D%26D%20Computer%20Technology&linkid=1&newurl=http%3A%2F%2Fwww.ddcomputer.com.au&query=Enzatec%20SP308&uca=240-0-0&kwi=&rpos=7" style="text-decoration:none" onMouseOver="this.style.textDecoration='underline'" onMouseOut="this.style.textDecoration='none'">D&D Computer Technology</a> (NSW) | www.ddcomputer.com.au | updated: 19-05-2012</td></tr><tr valign="top"><td align="left"><a title="DIY IT Supply: Click to see item" href="/cgi-bin/redirect.cgi?name=DIY%20IT%20Supply&linkid=2&newurl=http%3A%2F%2Fwww.diyit.com.au%2Findex.php%3Fdispatch%3Dcategories.view%26category_id%3D4044&query=Enzatec%20SP308&uca=267-0-0&kwi=&rpos=8" >$34.00</a><br></td><td valign="bottom">Enzatec SPK-308 Enzatec SP308 2.0 Speaker 2x2.5W 3.5mm Plug Retractable Cab...<br><font color="#808080"><a title="Click to visit the DIY IT Supply web site" href="/cgi-bin/redirect.cgi?name=DIY%20IT%20Supply&linkid=1&newurl=http%3A%2F%2Fwww.diyit.com.au&query=Enzatec%20SP308&uca=267-0-0&kwi=&rpos=8" style="text-decoration:none" onMouseOver="this.style.textDecoration='underline'" onMouseOut="this.style.textDecoration='none'">DIY IT Supply</a> (SA) | www.diyit.com.au | updated: 17-05-2012</td></tr><tr><td colspan="2"><img src="/images/rbluearrow.gif"> <font size="1" face="Verdana,Arial">Stores in <b><font color="#0080CC">bold</font></b> are <a href="javascript:void(0);" onClick="javascript:window.open('/cgi-bin/ret.cgi', 'info', 'toolbar=0,scrollbars=0,menubar=0,statusbar=0,width=300,height=200,resizable=0')" style="text-decoration:none" onMouseOver="this.style.textDecoration='underline'" onMouseOut="this.style.textDecoration='none'" >staticICE registered members</a></font></td></tr><tr><td height="15" colspan="2"> </td></tr><tr><td colspan="2"><a href="#top" style="font-size:10px"><b>top of page <img src="/images/ubluearrow.gif" border="0"></b></a></td></tr></table>
<!DOCTYPE HTML><html> <head> <meta charset="gb2312" /> <title></title> <style> body {font-size:12px;} </style> </head> <body> <div id="test"><table border="0" width="100%" cellpadding="5" cellspacing="0"><tr><td colspan="2"><table border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td><font size="2" face="Verdana,Arial" color="#000000"><b>Search Results</b></font></td><td width="150" align="right"><div class="addthis_default_style"><span class="addthis_separator"><font size=1>share</font></span> <a class="addthis_button_email"></a> <a class="addthis_button_facebook"></a> <a class="addthis_button_google"></a> <a class="addthis_button_twitter"></a></div><script type="text/javascript" src="/addthis_widget.js#username=xa-4bcc31a81caa95eb"></script></td></tr></table></td></tr> <tr><td colspan="2"><tr><td valign=top width="70"> <b>Price</b></td><td valign=top align="left"><b>Description</b></td></tr><tr valign="top"><td align="left"><a title="I-Tech: Click to see item" href="/cgi-bin/redirect.cgi?name=I-Tech&linkid=2&newurl=http%3A%2F%2Fwww.i-tech.com.au%2Fproducts%2F526_NEW_ARRIVAL.aspx&query=Enzatec%20SP308&uca=64-0-0&kwi=&rpos=1" >$27.00</a><br></td><td valign="bottom">Enzatec SP308 2.0 Speaker 2x2.5W 3.5mm Plug Retractable Cable Rechargeable ...<br><font color="#808080"><a title="Click to visit the I-Tech web site" href="/cgi-bin/redirect.cgi?name=I-Tech&linkid=1&newurl=http%3A%2F%2Fwww.i-tech.com.au&query=Enzatec%20SP308&uca=64-0-0&kwi=&rpos=1" style="text-decoration:none" onMouseOver="this.style.textDecoration='underline'" onMouseOut="this.style.textDecoration='none'">I-Tech</a> (NSW) | www.i-tech.com.au | updated: 16-05-2012</td></tr><tr valign="top"><td align="left"><a title="VTech Industries: Click to see item" href="/cgi-bin/redirect.cgi?name=VTech%20Industries&linkid=2&newurl=http%3A%2F%2Fwww.vtechindustries.com.au%2Fspeaker-systems%2Fenzatec&query=Enzatec%20SP308&uca=217-0-0&kwi=&rpos=3" >$27.94</a><br></td><td valign="bottom">Enzatec SP308 2.0 Speaker 2x2.5W 3.5mm Plug Retractable Cable Rechargeable ...<br><font color="#808080"><a title="Click to visit the VTech Industries web site" href="/cgi-bin/redirect.cgi?name=VTech%20Industries&linkid=1&newurl=http%3A%2F%2Fwww.vtechindustries.com.au&query=Enzatec%20SP308&uca=217-0-0&kwi=&rpos=3" style="text-decoration:none" onMouseOver="this.style.textDecoration='underline'" onMouseOut="this.style.textDecoration='none'">VTech Industries</a> (WA) | www.vtechindustries.com.au | updated: 17-05-2012</td></tr><tr valign="top"><td align="left"><a title="Megaware Computers: Click to see item" href="/cgi-bin/redirect.cgi?name=Megaware%20Computers&linkid=2&newurl=http%3A%2F%2Fwww.megaware.com.au%2Findex.php%3Fmain_page%3Dindex%26cPath%3D1497%26sort%3D2a%26page%3D10&query=Enzatec%20SP308&uca=564-0-0&kwi=&rpos=5" >$29.00</a><br></td><td valign="bottom">Enzatec SP308 2.0 Speaker 2x2.5W 3.5mm Plug Retractable Cable Rechargeable ...<br><font color="#808080"><a title="Click to visit the Megaware Computers web site" href="/cgi-bin/redirect.cgi?name=Megaware%20Computers&linkid=1&newurl=http%3A%2F%2Fwww.megaware.com.au&query=Enzatec%20SP308&uca=564-0-0&kwi=&rpos=5" style="text-decoration:none" onMouseOver="this.style.textDecoration='underline'" onMouseOut="this.style.textDecoration='none'">Megaware Computers</a> (NSW) | www.megaware.com.au | updated: 16-05-2012</td></tr><tr valign="top"><td align="left"><a title="D&D Computer Technology: Click to see item" href="/cgi-bin/redirect.cgi?name=D%26D%20Computer%20Technology&linkid=2&newurl=http%3A%2F%2Fwww.ddcomputer.com.au%2Fparts_SPK_Speakers.html&query=Enzatec%20SP308&uca=240-0-0&kwi=&rpos=7" >$33.00</a><br></td><td valign="bottom">Enzatec SP308 2.0 Speaker 2x2.5W 3.5mm Plug Retractable Cable Rechargeable ...<br><font color="#808080"><a title="Click to visit the D&D Computer Technology web site" href="/cgi-bin/redirect.cgi?name=D%26D%20Computer%20Technology&linkid=1&newurl=http%3A%2F%2Fwww.ddcomputer.com.au&query=Enzatec%20SP308&uca=240-0-0&kwi=&rpos=7
[解决办法]
$html=<<<eof<table border="0" width="100%" cellpadding="5" cellspacing="0"> <tr><td colspan="2"><table border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td><font size="2" face="Verdana,Arial" color="#000000"><b>Search Results</b></font></td><td width="150" align="right"><div class="addthis_default_style"><span class="addthis_separator"><font size=1>share</font></span> <a class="addthis_button_email"></a> <a class="addthis_button_facebook"></a> <a class="addthis_button_google"></a> <a class="addthis_button_twitter"></a></div><script type="text/javascript" src="/addthis_widget.js#username=xa-4bcc31a81caa95eb"></script></td></tr></table></td></tr> <tr><td colspan="2"><tr><td valign=top width="70"> <b>Price</b></td><td valign=top align="left"><b>Description</b></td></tr> <tr valign="top"><td align="left"><a title="I-Tech: Click to see item" href="/cgi-bin/redirect.cgi?name=I-Tech&linkid=2&newurl=http%3A%2F%2Fwww.i-tech.com.au%2Fproducts%2F526_NEW_ARRIVAL.aspx&query=Enzatec%20SP308&uca=64-0-0&kwi=&rpos=1" >$27.00</a><br></td><td valign="bottom">Enzatec SP308 2.0 Speaker 2x2.5W 3.5mm Plug Retractable Cable Rechargeable ...<br><font color="#808080"><a title="Click to visit the I-Tech web site" href="/cgi-bin/redirect.cgi?name=I-Tech&linkid=1&newurl=http%3A%2F%2Fwww.i-tech.com.au&query=Enzatec%20SP308&uca=64-0-0&kwi=&rpos=1" style="text-decoration:none" onMouseOver="this.style.textDecoration='underline'" onMouseOut="this.style.textDecoration='none'">I-Tech</a> (NSW) | www.i-tech.com.au | updated: 16-05-2012</td></tr> <tr valign="top"><td align="left"><a title="VTech Industries: Click to see item" href="/cgi-bin/redirect.cgi?name=VTech%20Industries&linkid=2&newurl=http%3A%2F%2Fwww.vtechindustries.com.au%2Fspeaker-systems%2Fenzatec&query=Enzatec%20SP308&uca=217-0-0&kwi=&rpos=3" >$27.94</a><br></td><td valign="bottom">Enzatec SP308 2.0 Speaker 2x2.5W 3.5mm Plug Retractable Cable Rechargeable ...<br><font color="#808080"><a title="Click to visit the VTech Industries web site" href="/cgi-bin/redirect.cgi?name=VTech%20Industries&linkid=1&newurl=http%3A%2F%2Fwww.vtechindustries.com.au&query=Enzatec%20SP308&uca=217-0-0&kwi=&rpos=3" style="text-decoration:none" onMouseOver="this.style.textDecoration='underline'" onMouseOut="this.style.textDecoration='none'">VTech Industries</a> (WA) | www.vtechindustries.com.au | updated: 17-05-2012</td></tr> <tr valign="top"><td align="left"><a title="Megaware Computers: Click to see item" href="/cgi-bin/redirect.cgi?name=Megaware%20Computers&linkid=2&newurl=http%3A%2F%2Fwww.megaware.com.au%2Findex.php%3Fmain_page%3Dindex%26cPath%3D1497%26sort%3D2a%26page%3D10&query=Enzatec%20SP308&uca=564-0-0&kwi=&rpos=5" >$29.00</a><br></td><td valign="bottom">Enzatec SP308 2.0 Speaker 2x2.5W 3.5mm Plug Retractable Cable Rechargeable ...<br><font color="#808080"><a title="Click to visit the Megaware Computers web site" href="/cgi-bin/redirect.cgi?name=Megaware%20Computers&linkid=1&newurl=http%3A%2F%2Fwww.megaware.com.au&query=Enzatec%20SP308&uca=564-0-0&kwi=&rpos=5" style="text-decoration:none" onMouseOver="this.style.textDecoration='underline'" onMouseOut="this.style.textDecoration='none'">Megaware Computers</a> (NSW) | www.megaware.com.au | updated: 16-05-2012</td></tr> <tr valign="top"><td align="left"><a title="D&D Computer Technology: Click to see item" href="/cgi-bin/redirect.cgi?name=D%26D%20Computer%20Technology&linkid=2&newurl=http%3A%2F%2Fwww.ddcomputer.com.au%2Fparts_SPK_Speakers.html&query=Enzatec%20SP308&uca=240-0-0&kwi=&rpos=7" >$33.00</a><br></td><td valign="bottom">Enzatec SP308 2.0 Speaker 2x2.5W 3.5mm Plug Retractable Cable Rechargeable ...<br><font color="#808080"><a title="Click to visit the D&D Computer Technology web site" href="/cgi-bin/redirect.cgi?name=D%26D%20Computer%20Technology&linkid=1&newurl=http%3A%2F%2Fwww.ddcomputer.com.au&query=Enzatec%20SP308&uca=240-0-0&kwi=&rpos=7" style="text-decoration:none" onMouseOver="this.style.textDecoration='underline'" onMouseOut="this.style.textDecoration='none'">D&D Computer Technology</a> (NSW) | www.ddcomputer.com.au | updated: 19-05-2012</td></tr> <tr valign="top"><td align="left"><a title="DIY IT Supply: Click to see item" href="/cgi-bin/redirect.cgi?name=DIY%20IT%20Supply&linkid=2&newurl=http%3A%2F%2Fwww.diyit.com.au%2Findex.php%3Fdispatch%3Dcategories.view%26category_id%3D4044&query=Enzatec%20SP308&uca=267-0-0&kwi=&rpos=8" >$34.00</a><br></td><td valign="bottom">Enzatec SPK-308 Enzatec SP308 2.0 Speaker 2x2.5W 3.5mm Plug Retractable Cab...<br><font color="#808080"><a title="Click to visit the DIY IT Supply web site" href="/cgi-bin/redirect.cgi?name=DIY%20IT%20Supply&linkid=1&newurl=http%3A%2F%2Fwww.diyit.com.au&query=Enzatec%20SP308&uca=267-0-0&kwi=&rpos=8" style="text-decoration:none" onMouseOver="this.style.textDecoration='underline'" onMouseOut="this.style.textDecoration='none'">DIY IT Supply</a> (SA) | www.diyit.com.au | updated: 17-05-2012</td></tr> <tr><td colspan="2"><img src="/images/rbluearrow.gif"> <font size="1" face="Verdana,Arial">Stores in <b><font color="#0080CC">bold</font></b> are <a href="javascript:void(0);" onClick="javascript:window.open('/cgi-bin/ret.cgi', 'info', 'toolbar=0,scrollbars=0,menubar=0,statusbar=0,width=300,height=200,resizable=0')" style="text-decoration:none" onMouseOver="this.style.textDecoration='underline'" onMouseOut="this.style.textDecoration='none'" >staticICE registered members</a></font></td></tr><tr><td height="15" colspan="2"> </td></tr><tr><td colspan="2"><a href="#top" style="font-size:10px"><b>top of page <img src="/images/ubluearrow.gif" border="0"></b></a></td></tr></table>eof;preg_match_all('/\|\s+(.*)\s+\| /U',$html,$m);print_r($m[1]);
[解决办法]
$str=preg_replace('/<table width="100%" border="0" cellspacing="0" cellpadding="4">(.*?)<\/table>/s','',$str);