PHP preg_将所有链接替换为#


php preg_replace all the link with #

一篇文章中的单词比较多,有些是英文,有些是拉丁文,现在,如何使用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...
<?php
$old = '<a href="#next">flow to the next</a> ';
$new = preg_replace('/(<a href="'#.*?">)(.*?)<'/a>/is', '$2', $old); 
echo $new;
演示