Sequence of logical OR in ES6/Unicode regular expression in Chrome ✗ vs Firefox ✓ Sequence of logical OR in ES6/Unicode regular expression in Chrome ✗ vs Firefox ✓ google-chrome google-chrome

Sequence of logical OR in ES6/Unicode regular expression in Chrome ✗ vs Firefox ✓


Without the u flag, your regexp works, and this is no wonder, since in the BMP (=no "u") mode it compares 16-bit "units" to 16-bit "units", that is, a surrogate pair to another surrogate pair.

The behaviour in the "u" mode (which is supposed to compare codepoints and not units) looks indeed like a Chrome bug, in the meantime you can enclose each alternative in a group, which seems to work fine:

m = '🍤🍦🍋🍋🍦🍤'.match(/(🍤)|(🍦)|(🍋)/ug)console.log(m)// note that the groups must be capturing!// this doesn't work:m = '🍤🍦🍋🍋🍦🍤'.match(/(?:🍤)|(?:🍦)|(?:🍋)/ug)console.log(m)