Consider the following Unicode-heavy regular expression (emoji standing in for non-ASCII and extra-BMP characters):
''.match(/||/ug)
Firefox returns [ "", "", "", "", "", "" ]
.
Chrome 52.0.2743.116 and Node 6.4.0 both return null
! It doesn’t seem to care if I put the string in a variable and do str.match(…)
, nor if I build a RegExp object via new RegExp('||', 'gu')
.
(Chrome is ok with just ORing two sequences: ''.match(/|/ug)
is ok. It’s also ok with non-Unicode: 'aakkzzkkaa'.match(/aa|kk|zz/ug)
works.)
Am I doing something wrong? Is this a Chrome bug? The ECMAScript compatibility table says I should be ok with Unicode regexps.
(PS: The three emoji used in this example are just stand-ins. In my application, they’ll be arbitrary but distinct strings. But I wonder if the fact that ''.match(/[]/ug)
works in Chrome is relevant?)
Update Marked fixed on 12 April 2017 in Chromium and downstream (including Chrome and Node).