繁体   English   中英

Javascript正则表达式:如何检测url是否为http://形式 <any string without a dot> .one.two.com?

[英]Javascript Regex: How to detect if a url is of the form http://<any string without a dot>.one.two.com?

如果url的格式如下,如何在JavaScript函数中使用regex返回true:

http://<any string without a dot>.one.two.com

否则为假?

例如,对于以下情况,它将返回true:

http://helloworld.one.two.com , http://poop.one.two.com , etc.

例如,对于

http://rawr.zero.one.two.com , http://two.com , etc.

谢谢!

/^http:\\/\\/[^.]*\\.one\\.two\\.com$/

/^http:\/\/[^.]+\.one\.two\.com/
/^http:\/\/[^\.]+\.one\.two\.com$/

末尾的$是指示性的,否则http://something.one.two.com.blah也将匹配。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM