不带 http://www 的 url 正则表达式 [英] url regex without http://www
本文介绍了不带 http://www 的 url 正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要一个 url 正则表达式来验证 url 字符串 without http://www.
或 https://www.
>
有什么想法吗?
解决方案
保持 www
完整以保留子域可能是个好主意.像这样的正则表达式:
^([a-zA-Z0-9]+(\.[a-zA-Z0-9]+)+.*)$
将匹配一个没有协议前缀的 URL (http://
,https://
,ftp://
等).
i need a url regex which validates the url string without http://www.
or https://www.
any ideas?
解决方案
It would probably be a good idea to keep the www
's intact in order to preserve the sub-domain. A regex pattern like this:
^([a-zA-Z0-9]+(\.[a-zA-Z0-9]+)+.*)$
would match a URL that is not prefixed by a protocol (http://
,https://
,ftp://
,etc).
这篇关于不带 http://www 的 url 正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文