1 String var = "userNameAndPassword"; 2 Pattern humpPattern = Pattern.compile("[A-Z]"); 3 Matcher matcher = humpPattern.matcher(var); 4 StringBuffer sb = new StringBuffer(); 5 while (matcher.find()) { 6 matcher.appendReplacement(sb, "_" + matcher.group(0).toLowerCase()); 7 } 8 matcher.appendTail(sb);
9 sb.toString()就是转换后小写的值
标签:下划线,驼峰,matcher,StringBuffer,小写,Pattern,sb From: https://www.cnblogs.com/wjz666/p/16712045.html