public static String camelToUpper(String camel) {
camel = camel.replaceAll("\\+", "_PLUS");
camel = camel.replaceAll("\\-", "_MINUS");
camel = camel.replaceAll("&", "AND");
camel = camel.replaceAll("[/@()]", "_");
camel = camel.replaceAll("\\s", "_");
camel = camel.replaceAll("'", "");
boolean wasLower = false;
String out = "";
String upper = camel.toUpperCase();
for (int i = 0; i < camel.length(); i++) {
char c = upper.charAt(i);
boolean isUpper = (c == camel.charAt(i));
if (isUpper && wasLower && c != '_')
out = out + "_";
out = out + c;
wasLower = !isUpper;
}
if (out.substring(0, 1).matches("[0-9]"))
out = "_" + out;
out = out.replaceAll("_+", "_");
out = out.replaceAll("_$", "");
return out;
}