Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does ?! mean?

Tags:

regex

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

new RegExp('http:\/\/(?!' + location.hostname + ')')
like image 392
Ricky Avatar asked Aug 31 '12 07:08

Ricky


People also ask

What is ?! Used for?

(often represented by any of ?!, !?, ?!? or !?!), is an unconventional punctuation mark used in various written languages and intended to combine the functions of the question mark, or interrogative point, and the exclamation mark, or exclamation point, known in the jargon of printers and programmers as a "bang".

What is A ?! Called?

What Is an Interrobang? An interrobang (sometimes called an interabang or exclamation question mark) is a nonstandard double punctuation mark that combines the glyphs and functions of the question mark and exclamation point. The glyph for an interrobang is ‽, but you can also write it as !?, ?!, or ?!?

What is a question mark and an exclamation point?

That combination of a question mark and an exclamation mark is called an interrobang (or interabang) and it is actually a question mark superimposed on an exclamation mark. It can be used when a question is exclaimed.

What is an interrobang used for?

The interrobang combines the question mark (?) and the exclamation point (!) into a single punctuation mark. It conveys a question asked in an excited way. For example: Are you really coming over to my house on Friday‽


2 Answers

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

like image 52
Joey Avatar answered Oct 06 '22 18:10

Joey


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

like image 43
npinti Avatar answered Oct 06 '22 17:10

npinti