MatcherWrapper implements MatchResult { @Override public String group() { return matcher.group(); } MatcherWrapper(Pattern pattern, CharSequence input); static MatcherWrapper matcher(String pattern, String input); String replaceAll(String replacement); String replaceAll(Function<MatcherWrapper, String> replaceFunction); String replaceFirst(Function<MatcherWrapper, String> replaceFunction); String replaceFirst(String replacement); Pattern pattern(); MatcherWrapper reset(); @Override int start(); @Override int start(int group); int start(String name); @Override int end(); @Override int end(int group); int end(String name); @Override String group(); @Override String group(int group); String group(String name); @Override int groupCount(); boolean matches(); boolean find(); boolean find(int start); MatcherWrapper appendReplacement(StringBuffer sb, String replacement); StringBuffer appendTail(StringBuffer sb);  }
@Test public void testReplaceAll_Function() { test("(he)", "(hezzhe)", matcher -> matcher.group(1) + "$1fuk", "(he$1fukzzhe$1fuk)"); test("no", "some", matcher -> matcher.group(1) + "$1fuk", "some"); }
@Test public void testReplaceFirst_Function() { test2("(he)", "(hezzhe)", matcher -> matcher.group(1) + "$1fuk", "(he$1fukzzhe)"); test2("no", "some", matcher -> matcher.group(1) + "$1fuk", "some"); }