开发者

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

开发者 https://www.devze.com 2023-01-07 18:26 出处:网络
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 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

精彩评论

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