Try this regex:
(?<![{,:] )"(?![:,]| })
Description
Demo
Discussion
Firstly, I assume that your regex flavor supports lookbehind.
Secondly, how did I find this regex you'd say ? Often, when you build a regular expression, you either build it for matching what you want or you build it for matching what you don't want. I use the latter here.
This is the regex for matching valid double quotes:
(?<=[{,:] )"|"(?=[:,]| })
Demo: http://regex101.com/r/oX4uM5
As you can see in the demo, the regex (let's call it R
) doesn't capture invalid quotes. So the regex we are looking for is its (particular) opposite (ie !R
). particular because we'll take the opposite of the look(behind|ahead) but not the quote inside R
.
So
(?<=...)
becomes(?<!...)
(?=...)
becomes(?!...)
"|"
(read it" OR "
) becomes (" AND "
) simply"
hence the final regex at the top of this answer.