import re
regex = re.compile(r"[\w\d\-|\._ ]*(?:(?<!universal)(\.jar)|(\.litemod))", flags=re.MULTILINE)
test_str = ("Link_Info-mc1.7.10-0.3.1.litemod\n"
"Mantle-1.7.10-0.3.2.jar\n"
"MicdoodleCore-1.7-3.0.11.333.jar\n"
"MineTweaker3-1.7.10-3.0.9C.jar\n"
"ModTweaker 2-0.8.0.jar\n"
"MouseTweaks-2.4.4-mc1.7.10.jar\n"
"NEIIntegration-MC1.7.10-1.0.9.jar\n"
"NotEnoughItems-1.7.10-1.0.5.110-universal.jar")
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