我只是想验证linkedin的公共档案网址。我试过下面的概念
a = "https://in.linkedin.com/afadasdf"
p = re.compile('(http(s?)://|[a-zA-Z0-9\-]+\.|[linkedin])[linkedin/~\-]+\.[a-zA-Z0-9/~\-_,&=\?\.;]+[^\.,\s<]')
p.match(a)
上述概念运行良好。但是当我给出urlhttps://www.linkedin.com时,意味着它不起作用。谁能帮我验证这两个概念吗。在
Tags:
这种模式可能会有所帮助。在
我已经测试过了,对我来说效果很好。在
正是http(s)和www.之间的oring给了您上述问题。您可以将它们更改为*(即0或更多)。在
尽管你可能想把它限制在www上,而不是任何数字或字母?所以也许:
^{pr2}$您可以使用
urllib
模块,而不是将url与regex匹配:现在可以检查
netloc
和path
属性。在相关问题 更多 >
编程相关推荐