Match:
(?ix)\A
(# Scheme
(?P<scheme>[a-z][a-z0-9+\-.]*):
(# authority & path
//
(?P<user>[a-z0-9\-._~%!$&'()*+,;=]+@)? # User
(?P<host>[a-z0-9\-.~%]+ # Named host
| \[[a-f0-9:.]+\] # IPv6 host
| \[v[a-f0-9][a-z0-9\-._~%!$&'()*+,;=:]+\]) # IPvFuture host
(?P<port>:[0-9]+)? # Port
(?P<hostpath>(/[a-z0-9\-._~%!$&'()*+,;=:@]+)*/?) # Path
| # Path without authority
(?P<schemepath>/?[a-z0-9\-._~%!$&'()*+,;=:@]+
(/[a-z0-9\-._~%!$&'()*+,;=:@]+)*/?)?
)
|# Relative URL (no scheme or authority)
(P<relpath>
# Relative path
[a-z0-9\-._~%!$&'()*+,;=@]+(/[a-z0-9\-._~%!$&'()*+,;=:@]+)*/?
|# Absolute path
(/[a-z0\-._~%!$&'()*+,;=:@]+)+/?
)
)
# Query
(?P<query>\?[a-z0-9\-._~%!$&'()*+,;=:@/?]*)?
# Fragment
(?P<fragment>\#[a-z0-9\-.+~%!$&'()*+,;=:@/?]*)?
\Z
Result:
http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=zipcode&ie=UTF8&t=h&z=15&utput=embed
Python 正则表达式验证generic url
最新推荐文章于 2024-05-21 09:40:37 发布