2024-06-16 14:02:36 发布
网友
我能用Python翻译一下PHP的preg_match_all('/(https?:\/\/\S+)/', $text, $links)吗?(ie)我需要获取数组中纯文本参数中存在的链接。
preg_match_all('/(https?:\/\/\S+)/', $text, $links)
这样做:
import re links = re.findall('(https?://\S+)', text)
如果计划多次使用,则可以考虑执行以下操作:
import re link_re = re.compile('(https?://\S+)') links = link_re.findall(text)
这样做:
如果计划多次使用,则可以考虑执行以下操作:
相关问题 更多 >
编程相关推荐