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.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With