不会用preg_replace,那位帮写一下代码!
将HTML文件中的类似下面这段:<div id="r_tx不确定的数字" style="width:100%">
<table cellpadding="0" cellspacing="0">
<tr>
<td>
<a id="r1_t" href="http://www.xxx.com/xx/xxxxx.html" onmousedown="return fp(this,{en:'te',io:'x',x:'xxx',tp:'d',ec:'x',ex:'tsrc%3Dtxtx'},'false',0)"
class="L4" >xxx xxxxx xxxxxx xxx xxxx xxxxx</a>
</td>
</tr>
</table>
</div>替换为:<div id="r_tx不确定的数字" style="width:100%">
<a onClick="openwin('http://www.xxx.com/xx/xxxxx.html')" href="#">xxx xxxxx xxxxxx xxx xxxx xxxxx</a>
</div>需要多次替换,X表示不确写的内容
将HTML文件中的类似下面这段:<div id="r_tx不确定的数字" style="width:100%">
<table cellpadding="0" cellspacing="0">
<tr>
<td>
<a id="r1_t" href="http://www.xxx.com/xx/xxxxx.html" onmousedown="return fp(this,{en:'te',io:'x',x:'xxx',tp:'d',ec:'x',ex:'tsrc%3Dtxtx'},'false',0)"
class="L4" >xxx xxxxx xxxxxx xxx xxxx xxxxx</a>
</td>
</tr>
</table>
</div>替换为:<div id="r_tx不确定的数字" style="width:100%">
<a onClick="openwin('http://www.xxx.com/xx/xxxxx.html')" href="#">xxx xxxxx xxxxxx xxx xxxx xxxxx</a>
</div>需要多次替换,X表示不确写的内容
$str =<<<HTML
<div id="r_tx不确定的数字" style="width:100%">
<table cellpadding="0" cellspacing="0">
<tr>
<td>
<a id="r1_t" href="http://www.xxx.com/xx/xxxxx.html" onmousedown="return fp(this,{en:'te',io:'x',x:'xxx',tp:'d',ec:'x',ex:'tsrc%3Dtxtx'},'false',0)"
class="L4" >xxx xxxxx xxxxxx xxx xxxx xxxxx </a>
</td>
</tr>
</table>
</div>
HTML;
$reg = '/<table.+?<a.+?href="(.+?)".+?>(.+?)<\/a>.+<\/table>/is';
echo preg_replace($reg,'<a onclick="openwin(\'$1\')" href="#">$2</a>', $str);
?>
$str =<<<HTML
<div id="r_tx不确定的数字" style="width:100%">
<table cellpadding="0" cellspacing="0">
<tr>
<td>
<a id="r1_t" href="http://www.xxx.com/xx/xxxxx.html" onmousedown="return fp(this,{en:'te',io:'x',x:'xxx',tp:'d',ec:'x',ex:'tsrc%3Dtxtx'},'false',0)"
class="L4" >xxx xxxxx xxxxxx xxx xxxx xxxxx </a>
</td>
</tr>
</table>
</div>
HTML;
$reg = '/<table.+<a.+?href="(.+)".+>(.+)<\/a>.+<\/table>/isU';
echo preg_replace($reg,'<a onclick="openwin(\'$1\')" href="#">$2</a>', $str);
?>
<?php
$str =<<<HTML
<div id="r_tx不确定的数字" style="width:100%">
<table cellpadding="0" cellspacing="0">
<tr>
<td>
<a id="r1_t" href="http://www.xxx.com/xx/xxxxx.html" onmousedown="return fp(this,{en:'te',io:'x',x:'xxx',tp:'d',ec:'x',ex:'tsrc%3Dtxtx'},'false',0)"
class="L4" >xxx xxxxx xxxxxx xxx xxxx xxxxx </a>
</td>
</tr>
</table>
</div>
HTML;
$reg = '/<table.+<a.+href="(.+)".+>(.+)<\/a>.+<\/table>/isU';
echo preg_replace($reg,'<a onclick="openwin(\'$1\')" href="#">$2</a>', $str);
?>