-3
console.log(/^\\[Xx][a-z][0-9]/.test('\xd8'));
rollstuhlfahrer
  • 3,988
  • 9
  • 25
  • 38

1 Answers1

2

\x is an escape sequence for other cases. \xd8 is the escaped value for Ø.

This means, your regex test never saw any of those characters you entered. Therefore the result has to be false.

If you want to match those strings, you need to escape the basckslash:

a = '\\xd8';
console.log(/^\\[Xx][a-z][0-9]/.test(a));
rollstuhlfahrer
  • 3,988
  • 9
  • 25
  • 38