[英]Javascript Regex: How to detect if a url is of the form http://<any string without a dot>.one.two.com?
How can I use regex in a JavaScript function to return true if the url is of the form: 如果url的格式如下,如何在JavaScript函数中使用regex返回true:
http://<any string without a dot>.one.two.com
and false otherwise? 否则为假?
for example it would return true for the following: 例如,对于以下情况,它将返回true:
http://helloworld.one.two.com , http://poop.one.two.com , etc.
for example, it would return false for 例如,对于
http://rawr.zero.one.two.com , http://two.com , etc.
Thanks! 谢谢!
/^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.