def find_links(line):
 l = line.replace('%', '%%')
 regex = '(https?://[^ )]+)'
 return (re.sub(regex, '%s', l), [m.group(1) for m in re.finditer(regex, l)])

def find_links ( line ) : l = line . replace ( '%' , '%%' ) regex = '(https?://[^ )]+)' return ( re . sub ( regex , '%s' , l ) , [ m . group ( 1 ) for m in re . finditer ( regex , l ) ] )
find all links in the given line .