import re
regex = re.compile(r"(?<=^\$translateProvider\.translations\('de', {)[\s\S]*(?=}\)$)", flags=re.MULTILINE)
test_str = ("$translateProvider.translations('de', {\n"
" WASTE_MANAGEMENT: 'Abfallmanagement',\n"
" WASTE_TYPE_LIST: 'Abfallarten',\n"
" WASTE_ENTRY_LIST: 'Abfalleinträge',\n"
" WASTE_TYPE: 'Abfallart',\n"
" TREATMENT_TYPE: 'Behandlungsart',\n"
" TREATMENT_TYPE_STATUS: 'Status Behandlungsart',\n"
" DUPLICATED_TREATMENT_TYPE: 'Doppelte Behandlungsart',\n"
" TREATMENT_TYPE_LIST: 'Behandlungsarten',\n"
" TREATMENT_TARGET_LIST: 'Ziele Behandlungsarten',\n"
" TREATMENT_TARGET_ADD: 'Ziel Behandlungsart hinzufügen',\n"
" SITE_TARGET: 'Gebäudeziel',\n"
" WASTE_TREATMENT_TYPES: 'Abfallbehandlungsarten',\n"
" WASTE_TREATMENT_TARGETS: '{{Abfallbehandlungsziele}}',\n"
" WASTE_TREATMENT_TYPES_LIST: '{{Abfallbehandlungsarten}}',\n"
" WASTE_TYPE_ADD: 'Abfallart hinzufügen',\n"
" UNIT_ADD: 'Einheit hinzufügen'\n"
"})")
matches = regex.finditer(test_str)
for match_num, match in enumerate(matches, start=1):
print(f"Match {match_num} was found at {match.start()}-{match.end()}: {match.group()}")
for group_num, group in enumerate(match.groups(), start=1):
print(f"Group {group_num} found at {match.start(group_num)}-{match.end(group_num)}: {group}")
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Python, please visit: https://docs.python.org/3/library/re.html