import re
regex = re.compile(r"jquery-?[0-9.]*(.min|.slim|.slim.min)?\.js", flags=re.MULTILINE)
test_str = ("https://www.staging2.villageofalamance.com/wp-includes/js/jquery/jquery.min.js\n"
"https://www.staging2.villageofalamance.com/wp-includes/js/jquery/jquery.js\n"
"https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.js\n"
"https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.js\n"
"https://code.jquery.com/jquery-3.5.1.min.js\n"
"https://code.jquery.com/jquery-3.5.1.js\n"
"https://code.jquery.com/jquery-3.5.1.slim.js\n"
"https://code.jquery.com/jquery-3.5.1.slim.min.js\n"
"https://c0.wp.com/c/5.2.2/wp-includes/js/jquery/jquery.js\n\n\n"
"## Shouldn't be excluded\n"
"https://www.staging2.villageofalamance.com/wp-content/plugins/league-table/public/assets/js/tablesorter/jquery.tablesorter-min.js?ver=2.08\n"
"https://www.staging2.villageofalamance.com/wp-content/themes/bridge/js/plugins/jquery.appear.js?ver=5.6\n"
"https://www.staging2.villageofalamance.com/wp-content/themes/bridge/js/plugins/jquery.flexslider-min.js?ver=5.6")
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