programming-examples/python/Regular_Expression/Find urls in a string.py

5 lines
309 B
Python
Raw Normal View History

2019-11-15 12:59:38 +01:00
import re
text = '<p>Contents :</p><a href="http://w3resource.com">Python Examples</a><a href="http://github.com">Even More Examples</a>'
urls = re.findall('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', text)
print("Original string: ",text)
print("Urls: ",urls)