allowed_exts = 'png', 'jpg'
from urllib.parse import urlparse
url = urlparse('ftp://www.somewhere.com/over/the/rainbow/image.jpg')
url.scheme in allowed_schemes
url.path.rsplit('.', 1)[1] in allowed_exts
How can I match the start and end in Python's regex?