kotlin split by uppercase
val input = "HelloWorldGoodMorning"
val result = input.split("(?=[A-Z])".toRegex())
println(result)
Explanation:
- input: Create a variable named
input
and assign the value"HelloWorldGoodMorning"
to it. - result: Create a variable named
result
and assign the result of splitting theinput
string using the regular expression"(?=[A-Z])"
to it. This regular expression matches the position before any uppercase letter. - println(result): Print the
result
to the console.