import re
regex = re.compile(r"en\/(?:(?!history).)*?\/", flags=re.MULTILINE)
test_str = ("https://denissov.ru/en/barracuda_limited/\n"
"https://denissov.ru/en/barracuda_chronograph/\n"
"https://denissov.ru/en/barracuda_mechanical/\n"
"https://denissov.ru/en/speedster/\n"
"https://denissov.ru/en/free_rider/\n"
"https://denissov.ru/en/nau_automatic/\n"
"https://denissov.ru/en/lady_flower/\n"
"https://denissov.ru/en/enigma/\n"
"https://denissov.ru/en/number_one/\n"
"https://denissov.ru/en/history/\n"
"https://denissov.ru/en/wordhistory/\n"
"https://denissov.ru/en/historyword/\n"
"https://denissov.ru/en/histor_y/\n\n"
"https://denissov.ru/en/barracuda_limited/', '_top')\" style=\"cursor: pointer;\"")
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