Answers for "regex to extract url from string python"

1

python regex for a url

import re

url = '<p>Hello World</p><a href="http://example.com">More Examples</a><a href="http://example2.com">Even More Examples</a>'

urls = re.findall('https?://(?:[-\w.]|(?:%[\da-fA-F]{2}))+', url)

>>> print urls
['http://example.com', 'http://example2.com']
Posted by: Guest on April-26-2021

Code answers related to "regex to extract url from string python"

Python Answers by Framework

Browse Popular Code Answers by Language