To get the substring after a specific character in Kotlin, you can use the `substringAfter` method of the String class.
In this example,
str
with a value of "Hello,World"
.substringAfter
method with ','
as the delimiter to get the substring after the specified character.fun main() {
val str = "Hello,World"
val substring = str.substringAfter(',')
println("Substring after ',': $substring")
}
Substring after ',': World
In this example,
url
with a value of "https://example.com/page"
.substringAfter
method with '/'
as the delimiter to get the substring after the specified character.fun main() {
val url = "https://example.com/page"
val substring = url.substringAfter('/')
println("Substring after '/': $substring")
}
Substring after '/': /example.com/page
In this tutorial, we learned How to get Substring after Specific Character in Kotlin language with well detailed examples.