Naomi Naomi Naomi Naomi - 6 months ago 18
PHP Question

php regex Remove "-s from string

I need to remove "-s that making invalid json, how do I do it in php regex?


"name": "Steak "au Four" ",


in this situation remove "au Four"-s " quotes

Answer

This is the php code to match the two quotes within a quote:

$re = "/^\"[^\"]*?(\")[^\"]*?(\")[^\"]*?\"$/"; 
$str = "\"Steak \"au Four\" \""; 

preg_match($re, $str, $matches);

Sample demo here