import re
regex = re.compile(r"(?<=\))(.+?)(\d\/\d{4}.*)", flags=re.MULTILINE)
test_str = ("Cloud Innovators Solution (9 months)Social Media Marketing Specialist1/2020 - 10/2020\n"
"StoriCamPK (less than a month)Marketing Communications Manager7/2022\n"
"Coleman Estate Agents (13 years, 11 months)Director8/2009\n"
"Coleman Estate Agents NewYork (13 years, 11 months)Director8/2009\n"
"TCS (less than a month)Head of Search Engine Optimization ➤ Brand & Strategy || Go-to-market Strategy || Content Marketer8/2010\n"
"Collins Securities Pty Ltd (less than a month) Credit ManagerInvalid date\n\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