import re
regex = re.compile(r"^(?:ht|f)tps?://[^/]+/[^.]+\.([^?]+)\?*$", flags=re.MULTILINE)
test_str = "http://u.example.something.com/abc=aaadddrBccc2SgFV000ALK2Qddd_;_vvv=Yu3DUzBHNlzcHIEY29sYMTEzZHQ5NjUzBHNlY9sbwNiZjEEdnRpZANRMU0wMV8xBHBvcwMx/CC=20/RE=MU0wMV8xBHBvcwMx/UU=10/ZZ=http://hhh.w.example.com/?uv=xxxxxx878787xxxxxxxxjhkjhkjhjkhADFADFS-&u=http://wwww.example.com/%2fuuu-lllllll%2sdfg-afd-adsfadf%2asdfaf000%3asdfasdfasfd%3dbing%26uasdfadf%3dcpc%26asdfadf%3d_ASDF234_ASDF%26asdfasF_asdfasdf%3d%252Bfasdfadsf%2520%252Basdf%2520%252Bdesign%26asdfasdf_aasdf%3dlf9McvAV%7cFADF%7c4063555565%7cpkw%7c%252Bfree%2520%252Bpcb%2520%252Basdf%7casdf%7asdf%7adf%7adf%7c/PO=0/UJ=iasdf7PASDFASDF-?p=this+is+an+example;"
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