공부
[kotlin] camelToSnake
승가비
2022. 9. 21. 17:25
728x90
fun camelToSnake(camel: String): String {
if (StringUtils.isEmpty(camel)) {
return ""
}
var result = camel[0].lowercase()
for (i in 1 until camel.length) {
val t = camel[i]
if (t.isUpperCase()) {
result += "_"
}
result += t.lowercase()
}
return result
}
https://www.geeksforgeeks.org/convert-camel-case-string-to-snake-case-in-java/
Convert camel case string to snake case in Java - GeeksforGeeks
A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.
www.geeksforgeeks.org
728x90