Here you can find the source of camelCase2UnderscoreLowercase(String name)
public static String camelCase2UnderscoreLowercase(String name)
//package com.java2s; //License from project: Apache License public class Main { public static String camelCase2UnderscoreLowercase(String name) { return camelCase2Underscore(name).toLowerCase().replace('-', '_'); }/*from w ww .j av a2 s .c o m*/ public static String camelCase2Underscore(String name) { return camelCase2Delimiter(name, '_'); } private static String camelCase2Delimiter(String name, char delimiter) { if (name == null || !name.matches(".*[A-Z].*") || !name.matches(".*[a-z].*")) return name; String regex = "([a-zA-Z])([A-Z])"; String replacement = "$1" + delimiter + "$2"; return name.replaceAll(regex, replacement).replaceAll(regex, replacement); } }