如何用正则表达式去除超链接 本帖最后由 banporen 于 2011-02-28 22:30:58 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 $article1="<a href=\"#\"class=\"axxa\">kdkd</a>";$article2="<a href=\"#\" class=\"sadfe\">wgeawtg</a>";echo preg_replace('/^<[^>]*(class="axxa")[^>]*>(.*)<\/a>/','$2',$article1);echo '<br/>';echo preg_replace('/^<[^>]*(class="axxa")[^>]*>(.*)<\/a>/','$2',$article2);及时结贴 <?php$article=<<<eof<a href='/index.php' class="axxa">kdkd</a><a class="axxa" href='http://www.h2ero.cn'>kdkkdkd</a><a class="axxa" href='http://blog.h2ero.cn'>kdkkdkd</a>eof;$pattern='/<a(?:.*?)class="axxa"(?:.*?)>(.*?)<\/a>/is';preg_match_all($pattern,$article,$result);print_r($result[1]);?> $article1="<a href=\"#\"class=\"axxa\">kdkd</a>";$article2="<a href=\"#\" class=\"sadfe\">wgeawtg</a>";echo preg_replace('/^<[^>]*(class="axxa")[^>]*>(.*)<\/a>/','$2',$article1);echo '<br/>';echo preg_replace('/^<[^>]*(class="axxa")[^>]*>(.*)<\/a>/','$2',$article2);快来给我说说你我离婚后分组家庭的情况吧 这个代码要怎样改? smarty中if语句中的变量无效 求助:wordperss主题如何实现首页自动显示文章中第一张图片,请看代码。 如何修改SESSION的生存时间 怎么学习mysql数据库部分? PHP在LINUX下运行的问题 有用PHP实现FTP的代码吗? 如何获得? PHP是什么,和JSP,,,ASP是同一类吗 Use of undefined constant position - assumed 'position' (this will throw an Erro php ajax 的基础问题 如何正则出HTTP开头的JPG图片?
$article1="<a href=\"#\"class=\"axxa\">kdkd</a>";
$article2="<a href=\"#\" class=\"sadfe\">wgeawtg</a>";
echo preg_replace('/^<[^>]*(class="axxa")[^>]*>(.*)<\/a>/','$2',$article1);
echo '<br/>';
echo preg_replace('/^<[^>]*(class="axxa")[^>]*>(.*)<\/a>/','$2',$article2);
及时结贴
<?php
$article=<<<eof
<a href='/index.php' class="axxa">kdkd</a>
<a class="axxa" href='http://www.h2ero.cn'>kdkkdkd</a>
<a class="axxa" href='http://blog.h2ero.cn'>kdkkdkd</a>
eof;
$pattern='/<a(?:.*?)class="axxa"(?:.*?)>(.*?)<\/a>/is';
preg_match_all($pattern,$article,$result);
print_r($result[1]);
?>
$article2="<a href=\"#\" class=\"sadfe\">wgeawtg</a>";
echo preg_replace('/^<[^>]*(class="axxa")[^>]*>(.*)<\/a>/','$2',$article1);
echo '<br/>';
echo preg_replace('/^<[^>]*(class="axxa")[^>]*>(.*)<\/a>/','$2',$article2);快来给我说说你我离婚后分组家庭的情况吧