import re
regex = re.compile(r"^([\w\.]+)\s*\d[\d\.\-]*\w*", flags=re.MULTILINE)
test_str = ("3rosCore 2.0.9\n"
"3rosCore 2.0.9-rc\n"
"3rosCore 2.0.8\n"
"3rosCore 2.0.8-rc\n"
"3rosCore 2.0.7\n"
"3rosCore 2.0.6\n"
"3rosCore 2.0.5\n"
"3rosCore 2.0.5-rc\n"
"3rosCore 2.0.4-rc\n"
"3rosCore 1.0.7\n"
"3rosCore 1.0.6\n"
"3rosCore 1.0.5\n"
"3rosCore 1.0.4\n"
"3rosCore 1.0.3\n"
"3rosCore 1.0.2\n"
"3rosCore 1.0.1\n"
"3rosWeb 2.0.0-rc\n"
"3rosWeb 1.0.2-rc\n"
"3rosWeb 1.0.1\n"
"3rosWeb 1.0.0\n"
"3rosWebApi 2.0.0\n"
"3rosWebApi 1.0.0\n"
"Actsis.ECharts.Standard 8.0.1695-beta\n"
"Actsis.ECharts.Standard 8.0.1691-beta\n"
"Actsis.ECharts.Standard 8.0.1689-beta")
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