2011-07-22 78 views
-2

还有一个文字中有更多的单词,有些是英文,有些是latins,现在,如何使用preg_replace,打破所有链接#?使类似:php preg_replace所有链接#

<a href="#next">flow to the next</a> =>flow to the next? (仅在长文本打破了链接与#

感谢。

不适合这项工作。

$new = preg_replace('/<a(?:.*?)(href="#)(?:.*?)>(.*?)<\/a>/is', '$2', $old); 
// this will also broken other links... 

回答

1
<?php 
$old = '<a href="#next">flow to the next</a> '; 
$new = preg_replace('/(<a href="\#.*?">)(.*?)<\/a>/is', '$2', $old); 
echo $new; 

demo