List of utility methods to do String Camel to Hyphen
String | camelCaseToHyphenated(String s) Transforms a string from camel-case to lower-case with hyphens. return s.replaceAll("([^^])([A-Z][a-z])", "$1-$2").toLowerCase(); |
String | camelCaseToHyphenCase(String s) Parse upper camel case to lower hyphen case. StringBuilder parsedString = new StringBuilder(s.substring(0, 1).toLowerCase()); for (char c : s.substring(1).toCharArray()) { if (Character.isUpperCase(c)) { parsedString.append("-").append(Character.toLowerCase(c)); } else { parsedString.append(c); return parsedString.toString(); |
String | camelCaseToHyphens(String s) camel Case To Hyphens String[] pieces = splitCamelCase(s); StringBuilder sb = new StringBuilder(); boolean first = true; for (String piece : pieces) { if (first) { first = false; } else { sb.append("-"); ... |