sb.append(']'); head = m.end(); }  if (head < string.length()) { sb.append(string.substring(head));
else if (Character.isUpperCase(ch)) { sb.append('['); sb.append(ch); sb.append(Character.toLowerCase(ch)); sb.append(']'); } else sb.append(ch);
  public static String sql_regcase(String string)  {    Pattern p = Pattern.compile("[a-zA-Z]");    Matcher m = p.matcher(string);    int head = 0;    StringBuilder sb = new StringBuilder();    while (m.find()) {      sb.append(string.substring(head, m.start()));      //substitute [Aa] for a, etc...      sb.append('[');      char ch = m.group().charAt(0);      if ((ch >= 'A') && ('Z' >= ch)) {        sb.append(ch);        sb.append((char) ('a' + ch - 'A'));      } else {        sb.append((char) ('A' + ch - 'a'));        sb.append(ch);      }      sb.append(']');      head = m.end();    }    if (head < string.length()) {      sb.append(string.substring(head));    }    return sb.toString();  }