6

/\p{Z}/u.test(' ') works on Chrome 71.0.3578.98 and returns true, but on Firefox 65.0 it throws the error: SyntaxError: invalid identity escape in regular expression

Is this a problem with ES implementation in Firefox, or I am using the regex wrong, and Chrome is just being nice and interprets that in the desired way?

Asu
  • 1,723
  • 2
  • 21
  • 32
  • 2
    FF does not support the features introduced in ECMAScript 2018 standard yet. BTW, why not just use `\s`? `/\s/.test(' ')` should work anywhere. – Wiktor Stribiżew Feb 05 '19 at 12:19
  • Ahh, I see.. I just gave a very simple example with \p{}. In reality I was using something more complicated for sets of different characters, but since the problem was caused by FF failing to interpret \p{}, this example seemed sufficient. Your comment really suffices for the answer to my question, if you care to post it as such. I didn't realise FF was that slow in implementing it. – Asu Feb 05 '19 at 12:29
  • 2
    I don't think this is a duplicate. Sure, it's related. However, that question and answer do not even mention Firefox. The question here though is much more specific and anyone could encounter this problem when they start trying to use \p regexes in Firefox and it doesn't work. They might benefit from a plain, simple and quick answer that there is just no support for these regexes in Firefox (as of version 65.0). This question isn't about how to create a regex, but rather about browser compatibility. – Asu Feb 05 '19 at 13:51
  • Your answer is there. See https://stackoverflow.com/a/48902765/3832970. – Wiktor Stribiżew Feb 05 '19 at 13:52

0 Answers0