0

I have encountered an issue when testing a char against a RegExp in JavaScript. The following line of code evaluates to true while it should evaluate to false.

/[\u10500-\u10D25]/.test('A');
solomancode
  • 61
  • 1
  • 10
  • [Your regex matches a lot of chars](https://regex101.com/r/ESy80d/1/), digits and letters included due to the `0-\u10D2` range, so `/[\u10500-\u10D25]/.test('A')` should evaluate to true. – Wiktor Stribiżew Sep 10 '18 at 06:53
  • If you want to match astral plane character, you need to use `u` flag, and proper syntax to specify astral plane character `/[\u{10500}-\u{10D25}]/u.test('\u{10500}')`, `/[\u{10500}-\u{10D25}]/u.test('a')`, – nhahtdh Sep 10 '18 at 07:45
  • @WiktorStribiżew: I remove that emoji question since it's for version 5. – nhahtdh Sep 10 '18 at 07:57
  • You might want to read this article as well: https://mathiasbynens.be/notes/javascript-unicode – nhahtdh Sep 10 '18 at 08:05

0 Answers0