Answers for "python regex url"

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
1

regex url in string python

import re
 
with open("path\url_example.txt") as file:
        for line in file:
            urls = re.findall('https?://(?:[-\w.]|(?:%[\da-fA-F]{2}))+', line)
            print(urls)
Posted by: Guest on June-22-2021
-1

python regex url

Don't try to make your own regular expression for matching URLs, use someone else's who has already solved such problems, like this one.
Posted by: Guest on March-20-2021

Python Answers by Framework

Browse Popular Code Answers by Language