将驼峰命名转为下划线名称
作者:互联网
private static Pattern humpPattern = Pattern.compile("[A-Z]");
// 将驼峰命名转为下划线名称
public static String humpToLine(String str) {
Matcher matcher = humpPattern.matcher(str);
StringBuffer sb = new StringBuffer();
while (matcher.find()) {
matcher.appendReplacement(sb, "_" + matcher.group(0).toLowerCase());
}
matcher.appendTail(sb);
return sb.toString();
}
标签:下划线,驼峰,Pattern,StringBuffer,static,matcher,sb,转为 来源: https://www.cnblogs.com/zxy-come-on/p/16161031.html