Here you can find the source of camelCaseToHyphens(String s)
public static String camelCaseToHyphens(String s)
//package com.java2s; //License from project: Open Source License public class Main { public static String camelCaseToHyphens(String s) { String[] pieces = splitCamelCase(s); StringBuilder sb = new StringBuilder(); boolean first = true; for (String piece : pieces) { if (first) { first = false;/* w ww.j a va2s .c o m*/ } else { sb.append("-"); } sb.append(piece.toUpperCase().toLowerCase()); } return sb.toString(); } public static String[] splitCamelCase(String s) { return s.split(String.format("%s|%s|%s", "(?<=[A-Z])(?=[A-Z][a-z])", "(?<=[^A-Z])(?=[A-Z])", "(?<=[A-Za-z])(?=[^A-Za-z])")); } }