JavaScript RegExp ?= Quantificatore
Esempio
Una ricerca per "è" seguita da "tutto":
let text = "Is this all there is";
let pattern = /is(?= all)/g;
Definizione e utilizzo
Il quantificatore ?= n corrisponde a qualsiasi stringa seguita da una stringa specifica n .
Suggerimento: usa il ?! n quantificatore per abbinare qualsiasi stringa NON seguita da una stringa specifica n .
Supporto browser
/(?=n)/
è una funzione ECMAScript1 (ES1).
ES1 (JavaScript 1997) è completamente supportato in tutti i browser:
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |
Sintassi
new RegExp("regexp(?=n)")
or
/regexp(?=n)/
Sintassi con modificatori
new RegExp("regexp(?=n)", "g")
or simply:
/regexp(?=n)/g