开发者

Regex to include all intranet sites but exclude http(s)://localhost

I am trying to come up with a JS regex that will include any intranet site (with the simpl开发者_JAVA技巧e definition of any host name that does not include .), but will exclude localhost.

I've got the first part: http(s)?\:\/\/[^\.\/]+(\/.*)* I am struggling with the second part. Any help would be appreciated.


You need to use a negative lookahead:

/^http(s)?\:\/\/(?!localhost[:\/])[^\.\/]+(\/.*)*$/
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜