通过preg_match_all获取,比如这样的一段html代码,<a href=http://www.hao123.com><strong>hao123</strong>网址之家</a>请教下面这段的正则怎么写?要取得的是 hao123网址之家 ,不要<strong>和</strong>标签preg_match_all("|<a href=(.*)>这里的正则应该怎么写?<\/a>|i",$strone,$strtwo);
调试欢乐多
$str = '<a href=http://www.hao123.com><strong>hao123</strong>网址之家</a>';
echo preg_replace('/<\/?strong>/is','',$str);$str = '<a href=http://www.hao123.com><strong>hao123</strong>网址之家</a>';
echo strip_tags($str);
$str = '<a href=http://www.hao123.com><strong>hao123</strong>网址之家</a>';
echo strip_tags($str, '<a>');
$strone = '<a href=http://www.hao123.com><strong>hao123</strong>网址之家</a>';
$output = preg_replace("/<([\w]+)[^>]*><([\w]+)[^>]*>(.*)<\/\\2>(.*)<\/\\1>/is", "\\3\\4", $strone);
print_r($output);
?>
<?php
$strone = '<a href=http://www.hao123.com><strong>hao123</strong>网址之家</a>';
preg_match_all("/<([\w]+)[^>]*><([\w]+)[^>]*>(.*)<\/\\2>(.*)<\/\\1>/is", $strone, $strtwo);
print_r($strtwo);
echo $strtwo[3].$strtwo[4];
?>