Naomi Naomi Naomi Naomi - 1 year ago 72
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 Source

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