captures-negative.js (1082B)
1 // Copyright (C) 2017 the V8 project authors. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 4 /*--- 5 esid: sec-assertion 6 description: > 7 Captures inside negative lookbehind. (They never capture.) 8 info: | 9 The production Assertion :: (?<=Disjunction) evaluates as follows: 10 1. Evaluate Disjunction with -1 as its direction argument to obtain a Matcher m. 11 2. Return an internal Matcher closure that takes two arguments, a State x and a Continuation 12 c, and performs the following steps: 13 a. Let d be a Continuation that always returns its State argument as a successful MatchResult. 14 b. Call m(x, d) and let r be its result. 15 c. If r is failure, return failure. 16 d. Let y be r's State. 17 e. Let cap be y's captures List. 18 f. Let xe be x's endIndex. 19 g. Let z be the State (xe, cap). 20 h. Call c(z) and return its result. 21 features: [regexp-lookbehind] 22 includes: [compareArray.js] 23 ---*/ 24 25 assert.compareArray("abcdef".match(/(?<!(^|[ab]))\w{2}/), ["de", undefined]); 26 27 reportCompare(0, 0);