$subject = '<a ref="aaa" href="http://www.google.com" title=`google`><span>Google</span></a>aaasdf<a href=http://www.baidu.com>111</a>jjjjj';
preg_match_all('/<a[^>]+href=(\"?)([^>]+)\1\s[^>]*>.+<\/a>.*/', $subject,$match);
print_r($match);
我想匹配两个<a>标签的href属性,上面写的有误,请大家帮我检查一下,谢谢了
preg_match_all('/<a[^>]+href=(\"?)([^>]+)\1\s[^>]*>.+<\/a>.*/', $subject,$match);
print_r($match);
我想匹配两个<a>标签的href属性,上面写的有误,请大家帮我检查一下,谢谢了
谢谢你的答复,我解决了。
preg_match_all('/<a[^>]+href=[\"\']?([^>\s\"]+)[\"\']?[^>]*>.*?<\/a>/', $subject,$match);
原来还要用非贪婪的办法才能解决的。