non-empty-class-ranges.js (1289B)
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: Extensions to NonemptyClassRanges production 7 info: | 8 The production NonemptyClassRanges :: ClassAtom-ClassAtom ClassRanges 9 evaluates as follows: 10 11 1. Evaluate the first ClassAtom to obtain a CharSet A. 12 2. Evaluate the second ClassAtom to obtain a CharSet B. 13 3. Evaluate ClassRanges to obtain a CharSet C. 14 4. Call CharacterRangeOrUnion(A, B) and let D be the resulting CharSet. 15 5. Return the union of CharSets D and C. 16 17 B.1.4.1.1 Runtime Semantics: CharacterRangeOrUnion Abstract Operation 18 19 1. If Unicode is false, then 20 a. If A does not contain exactly one character or B does not contain 21 exactly one character, then 22 i. Let C be the CharSet containing the single character - U+002D 23 (HYPHEN-MINUS). 24 ii. Return the union of CharSets A, B and C. 25 2. Return CharacterRange(A, B). 26 ---*/ 27 28 var match; 29 30 match = /[--\d]+/.exec('.-0123456789-.'); 31 assert.sameValue(match[0], '-0123456789-'); 32 33 match = /[--\dz]+/.exec('.-0123456789z-.'); 34 assert.sameValue(match[0], '-0123456789z-'); 35 36 reportCompare(0, 0);