-1

Why this regexp returns false for

/[\\]/igm.test('asdasdasd\asdasd');

and true for

/[\\]/igm.test('asdasdasd\\asdasd');

and when I try this it gives error, why..?

/[\\]/igm.test('abc\xyz');
Mr. A
  • 77
  • 2
  • 8

1 Answers1

0

\x is a character escape for an ASCII character, where the next two characters must be hexidecimal digits. So, \xyz is invalid because y and z aren't hex digits.

JohnnyHK
  • 305,182
  • 66
  • 621
  • 471