import re
regex = re.compile(r"modified:\s+((?>\w+\/?)+)[^)\v]*\)")
test_str = (" modified: apps/aaaaaa/bbbbbb/ccccff\n"
" modified: apps/ami (new commits)\n"
" modified: apps/assess (new commits)\n"
" modified: apps/ees121 (new commits)\n"
" modified: apps/energy_bourse (new commits)\n"
" modified: apps/gis (new commits)\n"
" modified: apps/hse (new commits)\n"
" modified: apps/aa/aaa/a/bb/b/bb/bc/c22/s/df/s/\n"
" modified: apps/management (new commits)\n"
" modified: apps/payesh (new commits)\n"
" modified: external_apps (modified content)\n"
" modified: modules/esb_server (new commits)\n"
" modified: modules/formbuilder (new commits, modified content)\n"
" modified: modules/reporting (new commits)\n"
" modified: modules/safir (new commits)\n"
" modified: modules/workflow (new commits)\n"
" modified: vendor/raya_framework/client (new commits)\n"
" modified: vendor/raya_framework/core (new commits)")
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