List of utility methods to do String Snake Case
String | toSnakeCase(String camelCase) to Snake Case if (camelCase == null) { throw new NullPointerException(); String[] parts = camelCase.split(SNAKE_CASE_SPLIT_REGEX); StringBuilder builder = new StringBuilder(camelCase.length() + (parts.length - 1)); for (int i = 0; i < parts.length - 1; i++) { builder.append(parts[i].toLowerCase()).append('_'); builder.append(parts[parts.length - 1].toLowerCase()); return builder.toString(); |
String | toSnakeCase(String s) to Snake Case return s.replaceAll("([a-z])([A-Z])", "$1_$2").toLowerCase(); |
String | toSnakeCase(String src) to Snake Case String dst = new String(); for (int i = 0; i < src.length(); i++) { char c = src.charAt(i); if ('A' <= c && c <= 'Z') { c += 32; if (i != 0) { dst += '_'; dst += c; return dst; |
String | toSnakeCase(String str) Convert a string to snake_case return str.replaceAll("([a-z])([A-Z])", "$1_$2").toLowerCase(); |
String | toSnakeCase(String str) Transforms a string to underscore-delimited representation. StringBuilder sb = new StringBuilder(); for (char c : str.toCharArray()) { if (Character.isLetter(c) || Character.isDigit(c)) { if (Character.isUpperCase(c)) { if (sb.length() > 0) { sb.append("_"); sb.append(Character.toLowerCase(c)); ... |
String | toSnakeCase(String str, boolean capitalize, Boolean upper) to Snake Case return changeSeparator(str, '_', capitalize, null, upper); |