RegexSelector implements Selector { @Override public String select(String text) { return selectGroup(text).get(group); } RegexSelector(String regexStr, int group);  RegexSelector(String regexStr); @Override String select(String text); @Override List<String> selectList(String text); RegexResult selectGroup(String text); List<RegexResult> selectGroupList(String text); @Override String toString();  }
@Test public void testRegexWithLeftBracketQuoted() { String regex = "\\(.+"; String source = "(hello world"; RegexSelector regexSelector = new RegexSelector(regex); String select = regexSelector.select(source); Assertions.assertThat(select).isEqualTo(source); }
@Test public void testRegexWithZeroWidthAssertions() { String regex = "^.*(?=\\?)(?!\\?yy)"; String source = "hello world?xx?yy"; RegexSelector regexSelector = new RegexSelector(regex); String select = regexSelector.select(source); Assertions.assertThat(select).isEqualTo("hello world"); regex = "\\d{3}(?!\\d)"; source = "123456asdf"; regexSelector = new RegexSelector(regex); select = regexSelector.select(source); Assertions.assertThat(select).isEqualTo("456"); }