import re
regex = re.compile(r"\s(\"[^\"\r\n\t]+\"|[a-z0-9\_]+)\s?\:\s([a-z\[\]0-9]+)\s?(\'[^\'\;]+\'|\"[^\"\;]+\"|of [^\"\;]+|[^\"\s\;]+|)( temporary)?\;", flags=re.MULTILINE | re.IGNORECASE)
test_str = (" \"lel lel\": Boolean;\n"
" \"lel lel\": Record \"Sales Header\";\n"
" lellel: Record \"Sales Header\";\n"
"Customer: Record Customer;\n"
" Lookup: Xmlport \"DataCustomer\";\n"
"Test1: Label \"Hallo\";\n"
"Test1: Label 'Hallo';\n"
" \"lel lel\": Integer;\n"
" AbsenceAmountType: Option \"Net Change\",\"Balance at Date\";\n"
" MATRIX_CellData: array[32] of Decimal;\n"
" MATRIX_ColumnCaption: array[32] of Text[1024];\n"
" CauseOfAbsenceFilter: Code[10];\n"
" NoSeriesCode: Code[20];\n"
" trigger Timer::Elapsed(sender: Variant; e: DotNet EventArgs)\n"
" ToolTip = 'Specifies how amounts are displayed. Net Change: The net change in the balance for the selected period. Balance at Date: The balance as of the last day in the selected period.';\n"
" \"Base X-Axis on\" := \"Base X-Axis on\"::Period;\n"
" MATRIX_GenerateColumnCaptions(SetWanted::Initial);\n"
" TempItemAttributeValue: Record \"Item Attribute Value\" temporary;")
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