code: static String likeToRegex(String like)
      {
          StringBuilder builder = new StringBuilder();
          boolean wasPercent = false;
          for (int i = 0; i < like.length(); ++i)
          {
              char c = like.charAt(i);
              if (isPlain(c))
              {
                  if (wasPercent)
                  {
                      wasPercent = false;
                      builder.append(".*");
                  }
                  builder.append(c);
              }
              else if (wasPercent)
              {
                  wasPercent = false;
                  if (c == '%')
                  {
                      builder.append('%');
                  }
                  else
                  {
                      builder.append(".*").append(c);
                  }
              }
              else
              {
                  if (c == '%')
                  {
                      wasPercent = true;
                  }
                  else
                  {
                      builder.append('\\').append(c);
                  }
              }
          }
          if (wasPercent)
          {
              builder.append(".*");
          }
          return builder.toString();
      }
docs: Like to regex.
  
  @param like
  the like
  @return the string