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[:\/])[^\.\/]+(\/.*)*$/
精彩评论