Use Regular Expressions to extract URL's

Novocastrian_Nomad gregory.j.baker at gmail.com
Fri Apr 30 14:09:54 EDT 2010


Or perhaps more generically:

>>> import re

>>> string = 'scatter "http://wwww.yahoo.com quotes and text anywhere www.google.com" "www.bing.com" or not'

>>> print re.findall(r'(?:http://|www.)[^"\s]+',string)

['http://wwww.yahoo.com', 'www.google.com', 'www.bing.com']



More information about the Python-list mailing list