Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP中的preg#u replace不能替换'`';_Php_Regex_Yii_Preg Replace - Fatal编程技术网

PHP中的preg#u replace不能替换'`';

PHP中的preg#u replace不能替换'`';,php,regex,yii,preg-replace,Php,Regex,Yii,Preg Replace,我试图从字符串中删除这个`符号。我试试这个: $string = preg_replace('`', '', $string); 但是你可以得到: 未找到结尾删除程序“”` 我做错了什么?正则表达式分隔符是“/”。将行更改为: $string=preg_replace('/`/','$string)preg\u replace是正则表达式str_replace是一个字符串。如果您不需要/不知道什么是正则表达式,请不要使用preg.*$string=str_replace(“”,“$string

我试图从字符串中删除这个`符号。我试试这个:

$string = preg_replace('`', '', $string);
但是你可以得到:

未找到结尾删除程序“
”`


我做错了什么?

正则表达式分隔符是“/”。将行更改为:


$string=preg_replace('/`/','$string)

preg\u replace
是正则表达式
str_replace
是一个字符串。如果您不需要/不知道什么是正则表达式,请不要使用
preg.*
$string=str_replace(“
”,“$string”)是您想要的。通过使用(这是世界上最大的搜索引擎-我很惊讶你没有听说过它)和搜索“字符串替换php”,可以搜索到它。虽然修复程序可以工作,但这是一个可怕的修复程序。这就像是一个机械师向某人解释要使用多少胶水来保持发动机在原位,或者是同一个机械师精确地解释在发动机开始阻塞之前,你可以用水稀释汽油多少<代码>str_replace
更好。此外,正则表达式分隔符不是
/
。这是你想要的
preg_replace('a'a',''$string)
$string = str_replace("`", "", $string);