Alex Lian Alex Lian - 1 year ago 115
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 ?

Answer Source

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

echo str_replace(",\"refresh\":18});", "}", $data);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download