What does ?! mean?

前端 未结 3 2068
梦毁少年i
梦毁少年i 2020-11-27 17:20

What does the ?! mean in the following regex expression?

new RegExp(\'http:\\/\\/(?!\' + location.hostname + \')\')
3条回答
  •  没有蜡笔的小新
    2020-11-27 17:54

    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).

提交回复
热议问题