Java tutorial
//package com.java2s; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static String getAttributeNameFromColName(String tableName) { Pattern p = Pattern.compile("_+(\\w?)"); Matcher m = p.matcher(tableName); StringBuffer sb = new StringBuffer(); while (m.find()) { if (m.start() != 0) m.appendReplacement(sb, m.group(1).toUpperCase()); else m.appendReplacement(sb, m.group(1).toLowerCase()); } m.appendTail(sb); return sb.toString(); } }