I need to find a key value pair of a JSON document using regular expression. The problem is that I can't properly understand how to scope the selection of the matching data.
Using this regexp,
"email"\s*:\s*".*"
it will select the entire document till it finds the last "
.
But i wanted to only select up-to the first "
so the selection would be like this:
"email":"foobar@foo.bar"
In order to achieve this I have tried using anchors like this:
"email"\s*:\s*^".*"$
but it is not working as expected. What would be a better way to achieve this?
Please note that if the email contains a double quote then the json string will be like this:
{"email":"foo@bar.c\"om"}
In this above scenario we might need to be able to skip all the \"
as well?
Also I need to fetch this data from a large file with 1.6m + inline JSON documents.
Playground: https://regexr.com/552pt