Possible Duplicate:
PHP: Regex to ignore escaped quotes within quotes
How to fix badly formatted JSON in PHP?
I have data that looks literally like this:
"manager1": "Richard "Dick" Smith, MD, MBA",
But it needs to look literally like this for it to work with JSON:
"manager1": "Richard \"Dick\" Smith, MD, MBA",
Note: The difference are backslashes only for the internal double-quotes of the nickname of Dick, while leaving the rest of the string without changes.
I'm having trouble dealing with the credentials (MD, MBA) separated by commas. How can this be done in PHP with regular expressions while only backslashing the internal double-quotes while preserving the rest of the string? Thanks!
This is not a duplicate of How to fix badly formatted JSON in PHP? because that routine can't handle the additional commas from the credentials.