Alex Lian Alex Lian - 6 months ago 27
PHP Question

regex, remove all but one character in PHP

I need your help.

I need to remove a pattern from a text file


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 ?


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

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