清除掉一段html文本內(nèi)容中的超鏈接最常見的寫法可以如下:
- $find="this string is my find";
- $string='<font color="red">這段內(nèi)容將要被替換掉</font>';//將超鏈接替換成的內(nèi)容
- echo ereg_replace('<a([^>]*)>([^<]*'.$find.'[^>]*)</a>','<font color="red">//2</font>',$content);
下面同時分享幾種獲取html文本內(nèi)容中的超鏈接的文本內(nèi)容方法:
- //方法一
- 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.+?>check user</a>/is',$str,$arr);
- print_r($arr);
新聞熱點
疑難解答