Can I have a translation of PHP’s preg_match_all('/(https?:\/\/\S+)/', $text, $link开发者_运维技巧s)
in Python, please? (ie) I need to get the links present in the plain text argument in an array.
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)
精彩评论