Mar-12-2018, 06:20 PM
link = '<a href="http://www.google.com">Google</a>'
re.search('<a[^>]+href=["\'](.*?)["\']',link,re.IGNORECASE).group()This code gives the output '<a href="http://www.google.com"'
re.findall('<a[^>]+href=["\'](.*?)["\']',link,re.IGNORECASE)But this code gives the output ['http://www.google.com']
Why are both the outputs different? findall() should work like search() except findall() gives a list of matches and search() gives only a single match.