hannesw@1841: /* hannesw@1841: * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. hannesw@1841: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. hannesw@1841: * hannesw@1841: * This code is free software; you can redistribute it and/or modify it hannesw@1841: * under the terms of the GNU General Public License version 2 only, as hannesw@1841: * published by the Free Software Foundation. hannesw@1841: * hannesw@1841: * This code is distributed in the hope that it will be useful, but WITHOUT hannesw@1841: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or hannesw@1841: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License hannesw@1841: * version 2 for more details (a copy is included in the LICENSE file that hannesw@1841: * accompanied this code). hannesw@1841: * hannesw@1841: * You should have received a copy of the GNU General Public License version hannesw@1841: * 2 along with this work; if not, write to the Free Software Foundation, hannesw@1841: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. hannesw@1841: * hannesw@1841: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA hannesw@1841: * or visit www.oracle.com if you need additional information or have any hannesw@1841: * questions. hannesw@1841: */ hannesw@1841: hannesw@1841: /** hannesw@1841: * JDK-8137240: Negative lookahead in RegEx breaks backreference hannesw@1841: * hannesw@1841: * @test hannesw@1841: * @run hannesw@1841: */ hannesw@1841: hannesw@1841: hannesw@1841: Assert.assertEquals('aa'.replace(/(a)(?!b)\1/gm, 'c'), 'c'); hannesw@1841: hannesw@1841: var result = 'aa'.match(/(a)(?!b)\1/); hannesw@1841: Assert.assertTrue(result.length === 2); hannesw@1841: Assert.assertTrue(result[0] === 'aa'); hannesw@1841: Assert.assertTrue(result[1] === 'a'); hannesw@1841: hannesw@1841: result = 'aa'.match(/(a)(?!(b))\2(a)/); hannesw@1841: Assert.assertTrue(result.length === 4); hannesw@1841: Assert.assertTrue(result[0] === 'aa'); hannesw@1841: Assert.assertTrue(result[1] === 'a'); hannesw@1841: Assert.assertTrue(result[2] === undefined); hannesw@1841: Assert.assertTrue(result[3] === 'a');