tags:

views:

40

answers:

1

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.

+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