identity-escape.js (1140B)
1 // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 /*--- 4 esid: sec-regular-expressions-patterns 5 es6id: B.1.4 6 description: Support for UnicodeIDContinue in IdentityEscape 7 info: | 8 IdentityEscape[U] :: 9 [+U] SyntaxCharacter 10 [+U] / 11 [~U] SourceCharacter but not c 12 ---*/ 13 14 var match; 15 16 match = /\C/.exec('ABCDE'); 17 assert.sameValue(match[0], 'C'); 18 19 match = /O\PQ/.exec('MNOPQRS'); 20 assert.sameValue(match[0], 'OPQ'); 21 22 match = /\8/.exec('789'); 23 assert.sameValue(match[0], '8'); 24 25 match = /7\89/.exec('67890'); 26 assert.sameValue(match[0], '789'); 27 28 match = /\9/.exec('890'); 29 assert.sameValue(match[0], '9'); 30 31 match = /8\90/.exec('78900'); 32 assert.sameValue(match[0], '890'); 33 34 match = /(.)(.)(.)(.)(.)(.)(.)(.)\8\8/.exec('0123456777'); 35 assert.sameValue( 36 match[0], 37 '0123456777', 38 'DecimalEscape takes precedence over IdentityEscape (\\8)' 39 ); 40 41 match = /(.)(.)(.)(.)(.)(.)(.)(.)(.)\9\9/.exec('01234567888'); 42 assert.sameValue( 43 match[0], 44 '01234567888', 45 'DecimalEscape takes precedence over IdentityEscape (\\9)' 46 ); 47 48 reportCompare(0, 0);