网址匹配正则表达式(python实现)

网址匹配正则表达式(python实现)

网址匹配正则表达式(python实现)

正则表达式部分如下:

pattern = re.compile(r'^(?:http|ftp)s?://'# http:// or https:// or ftp:// or ftps://r'(?:\S+(?::\S*)?@)?'# 可选的 用户:密码@ 部分r'(?:'# 开始匹配域名r'[A-Z0-9.-]+\.[A-Z]{2,6}'# 规范的域名,如 example.comr'|'# 或者r'localhost'# 本地 localhost
Could not load content