FormatPattern { public static List<Object> match(String formatString, String input) { return compile(formatString).matcher(input).match(); } FormatPattern(String formatString); @SuppressWarnings("OverridableMethodCallInConstructor")  FormatPattern(PatternConfiguration conf, String formatString); static List<Object> match(String formatString, String input); static FormatPattern compile(String formatString); static Pattern pattern(String formatString); static String regex(String formatString); Pattern getPattern(); Matcher regexMatcher(CharSequence csq); FormatMatcher matcher(CharSequence csq);  }
@Test public void test_match() { List<Object> result = FormatPattern.match("a%db%sc", "a123bfooc"); assertThat(result.get(0), isInstanceOf(Integer.class).that(is(123))); assertThat(result.get(1), isInstanceOf(String.class).that(is("foo"))); }
@Test public void test_regex() { List<Object> result = FormatPattern.match("a%iRm/(\\d+).*/c%d", "a123bfooc4"); assertThat(result.get(1), isInstanceOf(Integer.class).that(is(4))); MatchResult mr = (MatchResult) result.get(0); assertThat(mr.group(1), is("123")); }