我需要从字符串中提取一些文本,然后用一个字符在一个实例中删除而不是另一个字符替换该文本。希望这个例子会告诉你我的意思是(这是我至今):在preg_replace函数期间删除字符
$commentEntry = "@Bob1990 I think you are wrong...";
$commentText = preg_replace("/(@[^\s]+)/", "<a target=\"_blank\" href=\"http://www.youtube.com/comment_search?username=${1}$1\">$1</a>", $commentEntry);
我想要得到的结果是:
<a href="http://www.youtube.com/comment_search?username=Bob1990">@Bob1990</a> I think you are wrong...
但我越来越:
<a href="http://www.youtube.com/[email protected]">@Bob1990</a> I think you are wrong...
我一直在处理这个问题至少一个小时,几乎放弃了希望,所以任何帮助都非常感谢!