code: public StringBuilder removeDoctypeDeclaration(StringBuilder sb) {
          if (sb == null) {
              return null;
          }
          String patternStr = "(\\s*)<!DOCTYPE [^>]+>(.+)";
          Pattern ptn = Pattern.compile(patternStr, Pattern.DOTALL);
          Matcher m = ptn.matcher(sb);
          if (m.find()) {
              return new StringBuilder(m.group(1).trim() + "\n"
                      + m.group(2).trim());
          } else {
              return sb;
          }
      }
docs: <p>
  remove doctype declaration
  </p>