// Copyright 2022 Kevin Gibbons. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- description: Matching behavior with duplicate named capture groups esid: prod-GroupSpecifier features: [regexp-duplicate-named-groups] includes: [compareArray.js] ---*/ assert.compareArray(["b", "b"], "bab".match(/(?a)|(?b)/)); assert.compareArray(["b", "b"], "bab".match(/(?b)|(?a)/)); assert.compareArray(["aa", "aa", undefined], "aa".match(/(?:(?a)|(?b))\k/)); assert.compareArray(["bb", undefined, "bb"], "bb".match(/(?:(?a)|(?b))\k/)); let matchResult = "aabb".match(/(?:(?:(?a)|(?b))\k){2}/); assert.compareArray(["aabb", undefined, "bb"], matchResult); assert.sameValue(matchResult.groups.x, "bb"); let notMatched = "abab".match(/(?:(?:(?a)|(?b))\k){2}/); assert.sameValue(notMatched, null);