hannesw@1270: /* hannesw@1270: * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. hannesw@1270: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. hannesw@1270: * hannesw@1270: * This code is free software; you can redistribute it and/or modify it hannesw@1270: * under the terms of the GNU General Public License version 2 only, as hannesw@1270: * published by the Free Software Foundation. hannesw@1270: * hannesw@1270: * This code is distributed in the hope that it will be useful, but WITHOUT hannesw@1270: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or hannesw@1270: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License hannesw@1270: * version 2 for more details (a copy is included in the LICENSE file that hannesw@1270: * accompanied this code). hannesw@1270: * hannesw@1270: * You should have received a copy of the GNU General Public License version hannesw@1270: * 2 along with this work; if not, write to the Free Software Foundation, hannesw@1270: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. hannesw@1270: * hannesw@1270: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA hannesw@1270: * or visit www.oracle.com if you need additional information or have any hannesw@1270: * questions. hannesw@1270: */ hannesw@1270: hannesw@1270: /** hannesw@1270: * JDK-8073868: Regex matching causes java.lang.ArrayIndexOutOfBoundsException: 64 hannesw@1270: * hannesw@1270: * @test hannesw@1270: * @run hannesw@1270: */ hannesw@1270: hannesw@1270: function test(input) { hannesw@1270: var comma = input.indexOf(","); hannesw@1270: Assert.assertEquals(/([^\s]+),(.*)+/.exec(input)[0], input.trimLeft()); hannesw@1270: Assert.assertEquals(/([^\s]+),(.*)+/.exec(input)[1], input.substring(0, comma).trimLeft()); hannesw@1270: Assert.assertEquals(/([^\s]+),(.*)+/.exec(input)[2], input.substring(comma + 1)); hannesw@1270: Assert.assertEquals(/(.*)+/.exec(input)[0], input); hannesw@1270: Assert.assertEquals(/(.*)+/.exec(input)[1], input); hannesw@1270: } hannesw@1270: hannesw@1270: test(" xxxx, xxx xxxxxx xxxxxxxxx xxxxxxx, xxxx xxxxx xxxxx "); hannesw@1270: test(" xxxx, xxx xxxxxx xxxxxxxxx xxxxxxx, xxxx xxxxx xxxxx "); hannesw@1270: test("x, xxxxxxxxxx xxxxxxxxx xxxxxxx, xxxx xxxxx xxxxx "); hannesw@1270: hannesw@1270: Assert.assertEquals(/(?:\1a|())*/.exec("a")[0], "a"); hannesw@1270: Assert.assertEquals(/(?:\1a|())*/.exec("a")[1], undefined);