code: public static String convertRawUriToRegex(String rawUri) {
          StringBuilder builder = new StringBuilder();
  
          boolean inRegexp = false;
          boolean inVariablePlaceholder = false;
          boolean wasRegexp = false;
          String current = "";
          for (char c : rawUri.toCharArray()) {
              // First "{"
              if (!inVariablePlaceholder && c == '{') {
                  inVariablePlaceholder = true;
                  wasRegexp = false;
                  inRegexp = false;
                  current = "";
              }
  
              // No in a variable placeholder
              if (!inVariablePlaceholder) {
                  builder.append(c);
                  continue;
              }
  
              // In brace.
  
              // Ending "}"
              if (!inRegexp && c == '}') {
                  inVariablePlaceholder = false;
                  if (wasRegexp) {
                      continue;
                  }
                  if (current.endsWith("*")) {
                      builder.append(ANY_CHARS);
                  } else if (current.endsWith("+")) {
                      builder.append("(.+?)");
                  } else {
                      builder.append("([^/]+?)");
                  }
                  continue;
              }
  
              // In regex
              if (inRegexp  && c != '>') {
                  builder.append(c);
                  continue;
              }
  
              // Start a regex
              if (!inRegexp && c == '<') {
                  inRegexp = true;
                  wasRegexp = true;
                  builder.append("(");
                  continue;
              }
  
              // End of regex
              if (inRegexp && c == '>') {
                  inRegexp = false;
                  builder.append(")");
                  continue;
              }
  
              // We are in brace.
              current += c;
          }
  
          if (inRegexp) {
              throw new IllegalArgumentException("Invalid route uri - the regex part is not closed: " + rawUri);
          }
          if (inVariablePlaceholder) {
              throw new IllegalArgumentException("Invalid route uri - the variable placeholder is not closed: " + rawUri);
          }
  
          String s = builder.toString();
  
          // Replace ending * by (.*?)
          if (s.endsWith("*")) {
              s = s.substring(0, s.length() - 1) + ANY_CHARS;
          }
          return s;
      }
docs: Gets a raw uri like /{name}/id/* and returns /(.*)/id/*.
  
  @param rawUri the uri
  @return The regex