正则表达式,删除PHP中除一个字符外的所有字符

正则表达式,删除PHP中除一个字符外的所有字符

问题描述:

I need your help.

I need to remove a pattern from a text file ,"refresh":18});

But I don't need to delete curly bracket in this pattern, I need to save it.

My code

...
echo $data2 = str_replace(",\"refresh\":18});", "", $data);
...

How to change my regex to remove the pattern, but don not remove } charecter ?

我需要你的帮助。 p>

我需要删除一个模式 文本文件,“refresh”:18}); code> p>

但我不需要删除此模式中的花括号,我需要保存它。

我的代码 p>

  ... 
echo $ data2 = str_replace(“,”刷新\“:18});”,  “”,$ data); 
 ... 
  code>  pre> 
 
 

如何更改我的正则表达式以删除模式,但不要删除} charecter? p> div>

Why don't you just replace the whole pattern with character '}' ??? Just try:

echo str_replace(",\"refresh\":18});", "}", $data);