```java
private static Pattern humpPattern = Pattern.compile("[A-Z]|[1-9]");
```
> 此正则是包含数据库字段带数字的。
```java
/**
* 驼峰式字符串转换为下划线形式 如:userId-->user_id
* @param str
* @return
*/
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();
}
/**
* 将前端map入参驼峰式转为下划线式
* @param mapParam
* @return
*/
public static Map humpToLineMap( Map mapParam){
Map resultMap=new HashMap<>();
for(String key : mapParam.keySet()){
String value = (String)mapParam.get(key);//取出值
//把key转为下划线
String newKey= humpToLine(key);
resultMap.put(newKey,value);
}
return resultMap;
}
```