Use Case
I want to use regex to grab a very small part of json data with unknown location. Although Python has a json library, parsing all json data is slow. The json data has regular format.
Goal
For each occurrence of 1001
, I want to grab content in the innermost braces that enclose the occurrence
Code
import re
x = r'{123:{"a":100, "asdf":"example.com","at":1001},'\
'47289:{"a":20, "asdf":"test.org","at":20},}'
regex = r'{(.*?)1001(.*?)}'
print(re.match(regex, x).group(1))
Desired Result
{"a":100, "asdf":"example.com","at":1001}
Actual Result
123:{"a":100, "asdf":"example.com","at":
Questions
How to do this? How to do this fast?