What does the ?!
mean in the following regex expression?
new RegExp(\'http:\\/\\/(?!\' + location.hostname + \')\')
It's a negative lookahead, which means that for the expression to match, the part within (?!...)
must not match. In this case the regex matches http://
only when it is not followed by the current host name (roughly, see Thilo's comment).
It's a negative lookahead, you can check here for more information.
It's a look around.
location.hostname
must not follow http:\/\/