public static String likeToRegexpLike(String likePattern) {
    int start = 0;
    int end = likePattern.length();
    String prefix = "^";
    String suffix = "$";
    switch (likePattern.length()) {
      case 0:
        return "^$";
      case 1:
        if (likePattern.charAt(0) == '%') {
          return "";
        }
        break;
      default:
        if (likePattern.charAt(0) == '%') {
          start = indexOfFirstDifferent(likePattern, '%');
          if (start == -1) {
            return "";
          }
          prefix = "";
        }
        if (likePattern.charAt(likePattern.length() - 1) == '%') {
          end = indexOfLastDifferent(likePattern, '%');
          if (end == -1) { //this should never happen, but for clarity
            return "";
          }
          end++;
          suffix = "";
        }
        break;
    }

    likePattern = likePattern.substring(start, end);
    return escapeMetaCharsAndWildcards(likePattern, prefix, suffix);
  }
@Test
  public void testLeadingRepeatedWildcards() {
    String regexpLikePattern = RegexpPatternConverterUtils.likeToRegexpLike("%%%%%%%%%%%%%zz");
    assertEquals(regexpLikePattern, "zz$");
  }