What does ?! mean?

前端 未结 3 1984
梦毁少年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).

    0 讨论(0)
  • 2020-11-27 18:06

    It's a negative lookahead, you can check here for more information.

    0 讨论(0)
  • 2020-11-27 18:07

    It's a look around.

    location.hostname must not follow http:\/\/

    0 讨论(0)
提交回复
热议问题