[英]Replace tab & new line feed with empty string in JSON string
I have a JSON string which is like this when I log it: 我有一个JSON字符串,它在登录时是这样的:
..."items":{"0":"
\t\t\t\t\t"},"buys":{"0":"
\t\t\t\t\t"}}}, "sells":{}, "clients":{"test":{"0":"
\t\t\t\t"}...
What I want is to delete all new line feed (\\n) & tab characters(\\t)
from it and have a JSON string like this : 我想要从中删除所有
new line feed (\\n) & tab characters(\\t)
,并具有以下JSON字符串:
..."items":{},"buys":{}}}, "sells":{}, "clients":{"test":{}...
I have written a preg_replace
function like this : 我写了这样的
preg_replace
函数:
$json = preg_replace(['/\"0\"\:\n\"[\\t]+/'], [''], $json);
but When I log the JSON string they have not been deleted . 但是当我记录JSON字符串时,它们尚未被删除。
What should I do ? 我该怎么办 ?
You may use this regular expression 您可以使用此正则表达式
"[\t\n\r]"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.