List of utility methods to do String Camel Case to Snake Case
String | camelToSnake(final String camelStr) camel To Snake String ret = camelStr.replaceAll("([A-Z]+)([A-Z][a-z])", "$1_$2").replaceAll("([a-z])([A-Z])", "$1_$2"); return ret.toLowerCase(); |
String | camelToSnake(String camel, boolean upper) Converts camel case string (lower or upper/Pascal) to snake case, for example 'helloWorld' or 'HelloWorld' -> 'hello_world'. StringBuilder stringBuilder = new StringBuilder(); for (char c : camel.toCharArray()) { char nc = upper ? Character.toUpperCase(c) : Character.toLowerCase(c); if (Character.isUpperCase(c)) { stringBuilder.append('_').append(nc); } else { stringBuilder.append(nc); return stringBuilder.toString(); |
String | camelToSnake(String value) camel To Snake final char[] name = value.toCharArray(); final StringBuilder builder = new StringBuilder(); for (int i = 0; i < name.length; i++) { if (Character.isUpperCase(name[i]) || name[i] == '.' || name[i] == '$') { if (i != 0 && name[i - 1] != '.' && name[i - 1] != '$') { builder.append('_'); if (name[i] != '.' && name[i] != '$') { ... |
String | camelToSnakeCase(final String camelCase) converts ruby to camel case if (camelCase == null || camelCase.isEmpty()) { return ""; return camelCase.replaceAll("\\B([A-Z])", "_$1").toLowerCase(); |
String | camelToSnakeCase(String camelcase) camel To Snake Case return camelcase.replaceAll("([A-Z][a-z])", "_$1"); |
String | camelToSnakeCase(String string) Converts a string from CamelCase to snake_case. switch (string) { case "IO": return "io"; case "OS": return "os"; case "MD5": return "md5"; default: ... |
String | camelToSneakCase(String name) camel To Sneak Case StringBuilder sb = new StringBuilder(); int cur = 0; while (cur < name.length()) { char c = name.charAt(cur); if (!Character.isUpperCase(c)) { sb.append(c); cur++; continue; ... |
String | camelToUpperSnake(String camel) Converts camel case string (lower or upper/Pascal) to upper snake case, for example 'helloWorld' or 'HelloWorld' -> 'HELLO_WORLD'. return camelToSnake(camel, true);
|