Naomi Naomi Naomi Naomi - 2 years ago 93
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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download