php preg_replace行为不同

时间:2015-11-16 11:43:31

标签: php regex

我在论坛中有一段文字:

line one; 
line two; 
line three; 
line four; 

(结果由geshi制作 - $ geshi-> parse_code();)

我试图删除"
"使用

$result2=preg_replace("/&\#13;/", "", $result1);

但它不起作用。

奇怪的是:这在live php正则表达式测试器中成功完成:http://www.phpliveregex.com/

有专家可以就此提出建议吗?

非常感谢!

顺便说一句: 我尝试了var_dump并且输出没有改变,除了标题改为字符串(5411)"见http://saslab.org

我还尝试使用/\r/删除符号,但徒劳无功。

谢谢你的所有建议!

1 个答案:

答案 0 :(得分:0)

看看这是否是你需要的:

<?php 

$str="line one; &#13;line two; &#13;line three; &#13;line four; &#13;";
$result2 = str_replace("&#13", ":", $str);//replace : with your required string.
echo $result2;

?>