如下是django中做url验证的正则表达式:

1 regex = re.compile(
2         r'^(?:http|ftp)s?://' # http:// or https://
3         r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|' #domain...
4         r'localhost|' #localhost...
5         r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' # ...or ip
6         r'(?::\d+)?' # optional port
7         r'(?:/?|[/?]\S+)$', re.IGNORECASE)

 

相关文章:

  • 2022-12-23
  • 2021-11-23
  • 2021-11-24
  • 2022-12-23
  • 2022-12-23
  • 2021-12-26
猜你喜欢
  • 2021-12-09
  • 2021-11-24
  • 2021-12-05
  • 2022-02-27
  • 2021-11-17
  • 2021-12-03
相关资源
相似解决方案