public static UriTemplate create(String template, Charset charset) {
    return new UriTemplate(template, true, charset);
  }
@Test
  void simpleTemplateWithRegularExpressionsValidation() {
    String template = "https://www.example.com/{foo:[0-9]{4}}/{bar}";
    UriTemplate uriTemplate = UriTemplate.create(template, Util.UTF_8);
    assertThat(uriTemplate.getVariables()).contains("foo", "bar").hasSize(2);

    Map<String, Object> variables = new LinkedHashMap<>();
    variables.put("foo", "abcd");
    variables.put("bar", "stuff");

    /* the foo variable must be a number and no more than four, this should fail */
    assertThrows(IllegalArgumentException.class, () -> uriTemplate.expand(variables));
  }