Use urllib instead of regexes to work with URLs where possible