Can I have a translation of PHP’s preg_match_all('/(https?:\/\/\S+)/', $text, $links)
in Python, please? (ie) I need to get the links present in the plain text argument in an array.
views:
40answers:
1
+2
A:
This will do it:
import re
links = re.findall('(https?://\S+)', text)
If you plan to use this multiple times than you can consider doing this:
import re
link_re = re.compile('(https?://\S+)')
links = link_re.findall(text)
WoLpH
2010-10-05 16:57:35