高级会员
- 积分
- 585
- 金钱
- 585
- 注册时间
- 2020-5-25
- 在线时间
- 42 小时
|
/**
* 将属性名转化为数据库表属性命名格式
*/
fun upperCharToUnderLine(param: String?): String? {
val p: Pattern = Pattern.compile("[A-Z]")
if (param == null || param == "") {
return ""
}
val builder = StringBuilder(param)
val mc: Matcher = p.matcher(param)
var i = 0
while (mc.find()) {
builder.replace(mc.start() + i, mc.end() + i, "_" + mc.group().toLowerCase())
i++
}
if ('_' == builder[0]) {
builder.deleteCharAt(0)
}
return builder.toString()
}
|
|