Код: Выделить всё
_regex_pattern = re.compile(r'["\\')\]}]+?(?:\s+|(?=--)|$)', re.MULTILINE|re.UNICODE)
Код: Выделить всё
_regex_pattern.flags # outputs "40"
Код: Выделить всё
_regex_pattern.pattern # '["\\')\]}]+?(?:\s+|(?=--)|$)'
Код: Выделить всё
_regex_json = {'pattern': _regex_pattern.pattern, 'flags': _regex_pattern.flags}
with open('regex.json', 'w') as fout:
json.dump(_regex_json, fout)
Код: Выделить всё
with open('regex.json') as fin:
_regex_json = json.load(fin)
_regex_pattern_loaded = re.compile(
r"{}".format(_regex_json['pattern']), ???
)
Подробнее здесь: https://stackoverflow.com/questions/787 ... ag-objects