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0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))?\s*$
格式:http://或者https:// + [IPv6地址] + :端口
http://[xxxx]:xxxxx
https://[xxxx]:xxxxx
匹配方法:(2)(3)组合使用
先使用(2)匹配外部格式,再取中括号内部IPv6地址,使用(3)匹配IPv6地址是否是否符合8组4位16进制
正则式在线测试工具:https://tool.oschina.net/regex