import re
regex = re.compile(r"((?:http:\/\/+|www\.+|https:\/\/+)(?:\W+|\S+|\s+|.+)(?:\.net+|\.ro+))", flags=re.MULTILINE | re.IGNORECASE)
test_str = ("glass shoes door window door glasses. window glasses sunglasses\n"
"glass\n"
"asdblog\n"
"{www.asdblog.iqads.net}\n"
"{http://creator.iqads.ro/NESCAFE3in1}\n"
"http://twitter.com/share\n"
"http://cdn.iqads.ro/photos/tags/11912.png\n"
"http://cluj.tecomm.ro/\n"
"http://www.godmother.ro\n"
"http://www.facebook.com/godmotherBTL\n"
"http://twitter.com/share\n"
"http://media.iqads.ro/2015/10/rm2hb-cover-400.jpg\n"
"http://media.iqads.ro/2015/09/vv-cover-800-cover-400.jpg\n"
"http://media.iqads.ro/2015/08/razvan-mitoiu-photo-cover-400.jpg\n"
"http://media.iqads.ro/2015/06/dsc7179-cover-400.jpg\n"
"http://media.iqads.ro/2015/05/raluca2-cover-400.jpg\n"
"http://media.iqads.ro/2015/05/1me-cover-400.jpg\n"
"http://cdn.iqads.ro/photos/tags/263355.png\n"
"http://cdn.iqads.ro/photos/tags/32786.png\n"
"http://cdn.iqads.ro/photos/tags/22703.png\n"
"http://cdn.iqads.ro/photos/tags/23589.png\n"
"http://cdn.iqads.ro/photos/tags/228683.png\n"
"http://cdn.iqads.ro/photos/tags/23696.png\n"
"http://cdn.iqads.ro/photos/tags/16968.png\n"
"http://cdn.iqads.ro/photos/tags/263192.png\n"
"http://www.blueidea.ro\n"
"http://www.blueidea.ro")
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