@Udf(description = "Returns all substrings of the input that matches the given regex pattern")
  public List<String> regexpExtractAll(
      @UdfParameter(description = "The regex pattern") final String pattern,
      @UdfParameter(description = "The input string to apply regex on") final String input
  ) {
    return regexpExtractAll(pattern, input, 0);
  }
@Test
  public void shouldReturnSubstringCapturedByGroupNumber() {
    assertThat(udf.regexpExtractAll("(\\w*) (\\w*)", "test string", 1), contains("test"));
    assertThat(udf.regexpExtractAll("(\\w*) (\\w*)", "test string", 2), contains("string"));

    assertThat(udf.regexpExtractAll("(\\w*) (\\w*)", "test string another one", 1),
        contains("test", "", ""));
    assertThat(udf.regexpExtractAll("(\\w*) (\\w*)", "test string another one", 2),
        contains("string", "another", "one"));
    assertThat(udf.regexpExtractAll("(\\w+) (\\w+)", "test string another one", 1),
        contains("test", "another"));
    assertThat(udf.regexpExtractAll("(\\w+) (\\w+)", "test string another one", 2),
        contains("string", "one"));

    assertThat(udf.regexpExtractAll("(a)(b)?", "ab a", 1), contains("a", "a"));
    assertThat(udf.regexpExtractAll("(a)(b)?", "ab a", 2), contains("b", null));
  }