import re
regex = re.compile(r"(?![ab]\/)(([^ \t\n\r\f\v:\"])+?\.(html|py|css|js|txt|xml|json|vue))(\". line |:|\n| )(([0-9]+)*)", flags=re.MULTILINE)
test_str = ("diff --git a/src/give/forms.py b/src/give/forms.py\n\n\n"
" M give/locale/fr/LC_MESSAGES/django.po\n"
" M agive/models/translation.py\n"
" M give/views.py\n\n"
"Some problem at give/widgets.py:103\n\n"
"Traceback (most recent call last):\n"
" File \"/usr/lib/python3.10/unittest/case.py\", line 59, in testPartExecutor\n"
" yield\n"
" File \"/usr/lib/python3.10/unittest/case.py\", line 587, in run\n"
" self._callSetUp()\n"
" File \"/usr/lib/python3.10/unittest/case.py\", line 546, in _callSetUp\n"
" self.setUp()\n"
" File \"/home/projects/src/give/tests/test_models.py\", line 14, in setUp\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