可以用$str = preg_replace("/<a[^>]*href=[^>]*>|<\/[^a]*a[^>]*>/i","",$strhtml); 这段来实现需求,如果想要更多解决方法,可以参看以下的。
1、删除内容中的超链接
复制代码 代码如下:
ereg_replace('<a([^>]*)>([^<]*)</a>','<font color="red">\\2</font>',$content);
ereg_replace("<a [^>]*>|<\/a>","",$content);
2、消除包含特定词的超链接
复制代码 代码如下:
$find="this string is my find";
$string='<font color="red">替换掉了</font>';//将超链接替换成的内容
echo ereg_replace('<a([^>]*)>([^<]*'.$find.'[^>]*)</a>','<font color="red">\\2</font>',$content);
3、获取超链接文本内容
复制代码 代码如下:
//方法一
preg_match_all('/<(a|a)[s]{0,1}[w=":()]*>[nrn]*(check user)[nrn]*</(a|a)>/i',$string,$matches);
//方法二
preg_match_all('/<a[dd]*>check user</a>/i',$string,$matches);
print_r($matches);
//方法三
preg_match_all('/<a[^>]*>[^<]*</a>/i',$string,$matches);
print_r($matches);
//方法四
preg_match_all('/<a.+"/<a[^>]*href=[^>]*>|<\/[^a]*a[^>]*>/i","",$yearstr);
PHP,正则表达式
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
更新日志
- 黑鸭子.2005-《发烧DSD》柏菲[WAV分轨]
- 群星.1990-电影看板·人间道【宝丽金】【WAV+CUE】
- 周殷廷.2024-TO.WHOM.IT.MAY.CONCERN【环球】【FLAC分轨】
- 草蜢.1997-三人世界精选17首【宝丽金】【WAV+CUE】
- 【古琴音乐】管平湖《广陵散》2004[FLAC+CUE]
- 【中国民乐】《少数民族器乐·苗岭的早晨》2004[WAV+CUE]
- 【中国音乐】盛中国《新疆之春》2004[FLAC+CUE]
- 群星《音你而来 第8期》[320K/MP3][44.64MB]
- 群星《音你而来 第8期》[FLAC/分轨][121.21MB]
- 群星《十二女声Ⅲ》[WAV/CUE/分轨][626.4MB]
- 陈百强.1993-离不开...纪念歌集2CD【华纳】【WAV+CUE】
- 于台烟.2003-爱自己【乾坤唱片】【WAV+CUE】
- 群星.2024-我们永远是我们电影原声带【乐禾发文化】【FLAC分轨】
- 【中国民乐】张维良《秋江夜泊》2004[FLAC+CUE]
- 明达年度发烧碟MasterSuperiorAudiophile2011[DSF]