【发布时间】:2014-06-06 16:04:44
【问题描述】:
我正在尝试使用preg_replace 将\u003C 替换为<,但它返回相同的输入。
这是我的 preg_replace
preg_replace('/\\\\u003C/','<','name\u003Cname@example.com\u003E');
任何帮助。
【问题讨论】:
-
为什么要在模式中加入四个斜线
\\\\u003C?两个就够了。 -
@Pete_Gore:需要一对是因为您在 PHP 字符串文字中,另一对是因为您正在编写正则表达式。
-
我测试了
preg_replace('/\\u003C/','<','name\u003Cname@example.com\u003E');,效果很好 -
@Pete_Gore: I find that hard to believe.
-
为什么 OP 不使用
str_replace?
标签: php regex preg-replace