@Test public void testToJavaRegexWithCharacterClasses() { assertThat(toJavaRegex("[a-c]"), equalTo("[a-c]")); assertThat(toJavaRegex("Foo[bar]"), equalTo("Foo[bar]")); assertThat(toJavaRegex("[0-9]"), equalTo("[0-9]")); assertThat(toJavaRegex("[A-D]"), equalTo("[A-D]")); assertThat(toJavaRegex("border-[0-9]-DC?-*"), equalTo("border-[0-9]-DC\\w-.*")); assertThat(toJavaRegex("ge-1/2/[5-8]"), equalTo("ge-1/2/[5-8]")); assertThat(toJavaRegex("12.1[23]4.*.*/2[89]"), equalTo("12\\.1[23]4\\..*\\..*/2[89]")); }
public static String toJavaRegex(String wildcard) { GroupWildcard parser = Parboiled.createParser(GroupWildcard.class); BasicParseRunner<String> runner = new BasicParseRunner<>(parser.TopLevel()); ParsingResult<String> result = runner.run(wildcard); if (!result.matched) { throw new IllegalArgumentException("Unhandled input: " + wildcard); } return result.resultValue; }
GroupWildcard extends BaseParser<String> { public static String toJavaRegex(String wildcard) { GroupWildcard parser = Parboiled.createParser(GroupWildcard.class); BasicParseRunner<String> runner = new BasicParseRunner<>(parser.TopLevel()); ParsingResult<String> result = runner.run(wildcard); if (!result.matched) { throw new IllegalArgumentException("Unhandled input: " + wildcard); } return result.resultValue; } }
GroupWildcard extends BaseParser<String> { public static String toJavaRegex(String wildcard) { GroupWildcard parser = Parboiled.createParser(GroupWildcard.class); BasicParseRunner<String> runner = new BasicParseRunner<>(parser.TopLevel()); ParsingResult<String> result = runner.run(wildcard); if (!result.matched) { throw new IllegalArgumentException("Unhandled input: " + wildcard); } return result.resultValue; }  }
GroupWildcard extends BaseParser<String> { public static String toJavaRegex(String wildcard) { GroupWildcard parser = Parboiled.createParser(GroupWildcard.class); BasicParseRunner<String> runner = new BasicParseRunner<>(parser.TopLevel()); ParsingResult<String> result = runner.run(wildcard); if (!result.matched) { throw new IllegalArgumentException("Unhandled input: " + wildcard); } return result.resultValue; }  static String toJavaRegex(String wildcard); }
GroupWildcard extends BaseParser<String> { public static String toJavaRegex(String wildcard) { GroupWildcard parser = Parboiled.createParser(GroupWildcard.class); BasicParseRunner<String> runner = new BasicParseRunner<>(parser.TopLevel()); ParsingResult<String> result = runner.run(wildcard); if (!result.matched) { throw new IllegalArgumentException("Unhandled input: " + wildcard); } return result.resultValue; }  static String toJavaRegex(String wildcard);  }