/** * @author xichao.dong * @email 406592176@qq.com * @date 2014-8-15 上午8:50:38 * @company (开发公司) 珠海市冰川软件有限公司 * @copyright (版权) 本文件归属珠海市冰川软件有限公司所有 * @version V1.0 * @modify (修改) : 2014-8-15 上午8:50:38 xichao.dong * @Review (审核人) :xichao.dong */ package com.glacier.basic.util; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * @ClassName: GlacierUitls * @Description: TODO(这里用一句话描述这个类的作用) * @author xichao.dong * @email 406592176@qq.com * @date 2014-8-15 上午11:15:08 */ public class GlacierUitls { public static String camelTounderline(String param) { if (null == param || param.equals("")) { return ""; } Pattern p = Pattern.compile("[A-Z]"); StringBuilder builder = new StringBuilder(param); Matcher mc = p.matcher(param); int i = 0; while (mc.find()) { builder.replace(mc.start() + i, mc.end() + i, "_" + mc.group().toLowerCase()); i++; } if ('_' == builder.charAt(0)) { builder.deleteCharAt(0); } return builder.toString(); } }