@Test public void testSplitGetsArrayOfTextAroundMatches() { Pattern p = Pattern.compile("(a)(b)(?:c)(?<named>x)"); assertArrayEquals(new String[] {"foo ", " bar "}, p.split("foo abcx bar abcx")); // when the limit is specified, the last element contains // the remainder of the string assertArrayEquals(new String[] {"foo ", " bar abcx"}, p.split("foo abcx bar abcx", 2)); }