且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从字符串中检测并提取 url?

更新时间:2023-02-19 12:36:04

m.group(1) 给你第一个匹配组,即第一个捕获括号.这是(https?|ftp|file)

m.group(1) gives you the first matching group, that is to say the first capturing parenthesis. Here it's (https?|ftp|file)

您应该尝试查看 m.group(0) 中是否存在某些内容,或者用括号将所有模式括起来并再次使用 m.group(1).

You should try to see if there is something in m.group(0), or surround all your pattern with parenthesis and use m.group(1) again.

您需要重复查找函数以匹配下一个并使用新的组数组.

You need to repeat your find function to match the next one and use the new group array.