9
我可以在Python中翻譯PHP的preg_match_all('/(https?:\/\/\S+)/', $text, $links)
嗎? (ie)我需要獲取數組中的純文本參數中的鏈接。將PHP的preg_match_all翻譯爲Python
我可以在Python中翻譯PHP的preg_match_all('/(https?:\/\/\S+)/', $text, $links)
嗎? (ie)我需要獲取數組中的純文本參數中的鏈接。將PHP的preg_match_all翻譯爲Python
這將做到這一點:
import re
links = re.findall('(https?://\S+)', text)
如果你打算使用這個多次比你可以考慮這樣做:
import re
link_re = re.compile('(https?://\S+)')
links = link_re.findall(text)