I have some text of the form:
This is some text, and here's some in "double quotes"
"and here's a double quote:\" and some more", "text that follows"
The text contains strings within double quotes, as can be seen above. A double quoted may be escaped with a backslash (\
). In the above, there are three such strings:
"double quotes"
"and here's a double quote:\" and some more"
"text that follows"
To extract these strings, I tried the regex:
"(?:\\"|.)*?"
However, this gives me the following results:
>>> preg_match_all('%"(?:\\"|.)*?"%', $msg, $matches)
>>> $matches
[
[ "double quotes",
"and here's a double quote:\",
", "
]
]
How can I correctly obtain the strings?