endsWith
Returns true
if this char sequence ends with the specified character.
Since Kotlin
1.0Returns true
if this char sequence ends with the specified suffix.
Since Kotlin
1.0Returns true
if this string ends with the specified suffix.
Since Kotlin
1.0Parameters
the suffix with which this string should end with.
the flag indicating if the string characters should be compared with the suffix characters in a case-insensitive manner; by default, comparison is case-sensitive.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val str = "abcde"
println("str.endsWith(\"cde\") is ${str.endsWith("cde")}") // true
println("str.endsWith(\"CDE\") is ${str.endsWith("CDE")}") // false
println("str.endsWith(\"bcd\") is ${str.endsWith("bcd")}") // false
println("str.endsWith(\"_abcde\") is ${str.endsWith("_abcde")}") // false
//sampleEnd
}
import kotlin.test.*
fun main() {
//sampleStart
val str = "abcde"
println("str.endsWith(\"cde\", ignoreCase = true) is ${str.endsWith("cde", ignoreCase = true)}") // true
println("str.endsWith(\"CDE\", ignoreCase = true) is ${str.endsWith("CDE", ignoreCase = true)}") // true
println("str.endsWith(\"bcd\", ignoreCase = true) is ${str.endsWith("bcd", ignoreCase = true)}") // false
//sampleEnd
}
Returns true
if this string ends with the specified suffix.
Since Kotlin
1.1Parameters
the suffix with which this string should end with.
the flag indicating if the string characters should be compared with the suffix characters in a case-insensitive manner; by default, comparison is case-sensitive.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val str = "abcde"
println("str.endsWith(\"cde\") is ${str.endsWith("cde")}") // true
println("str.endsWith(\"CDE\") is ${str.endsWith("CDE")}") // false
println("str.endsWith(\"bcd\") is ${str.endsWith("bcd")}") // false
println("str.endsWith(\"_abcde\") is ${str.endsWith("_abcde")}") // false
//sampleEnd
}
import kotlin.test.*
fun main() {
//sampleStart
val str = "abcde"
println("str.endsWith(\"cde\", ignoreCase = true) is ${str.endsWith("cde", ignoreCase = true)}") // true
println("str.endsWith(\"CDE\", ignoreCase = true) is ${str.endsWith("CDE", ignoreCase = true)}") // true
println("str.endsWith(\"bcd\", ignoreCase = true) is ${str.endsWith("bcd", ignoreCase = true)}") // false
//sampleEnd
}
Returns true
if this string ends with the specified suffix.
Since Kotlin
1.0Parameters
the suffix with which this string should end with.
the flag indicating if the string characters should be compared with the suffix characters in a case-insensitive manner; by default, comparison is case-sensitive.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val str = "abcde"
println("str.endsWith(\"cde\") is ${str.endsWith("cde")}") // true
println("str.endsWith(\"CDE\") is ${str.endsWith("CDE")}") // false
println("str.endsWith(\"bcd\") is ${str.endsWith("bcd")}") // false
println("str.endsWith(\"_abcde\") is ${str.endsWith("_abcde")}") // false
//sampleEnd
}
import kotlin.test.*
fun main() {
//sampleStart
val str = "abcde"
println("str.endsWith(\"cde\", ignoreCase = true) is ${str.endsWith("cde", ignoreCase = true)}") // true
println("str.endsWith(\"CDE\", ignoreCase = true) is ${str.endsWith("CDE", ignoreCase = true)}") // true
println("str.endsWith(\"bcd\", ignoreCase = true) is ${str.endsWith("bcd", ignoreCase = true)}") // false
//sampleEnd
}
Returns true
if this string ends with the specified suffix.
Since Kotlin
1.3Parameters
the suffix with which this string should end with.
the flag indicating if the string characters should be compared with the suffix characters in a case-insensitive manner; by default, comparison is case-sensitive.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val str = "abcde"
println("str.endsWith(\"cde\") is ${str.endsWith("cde")}") // true
println("str.endsWith(\"CDE\") is ${str.endsWith("CDE")}") // false
println("str.endsWith(\"bcd\") is ${str.endsWith("bcd")}") // false
println("str.endsWith(\"_abcde\") is ${str.endsWith("_abcde")}") // false
//sampleEnd
}
import kotlin.test.*
fun main() {
//sampleStart
val str = "abcde"
println("str.endsWith(\"cde\", ignoreCase = true) is ${str.endsWith("cde", ignoreCase = true)}") // true
println("str.endsWith(\"CDE\", ignoreCase = true) is ${str.endsWith("CDE", ignoreCase = true)}") // true
println("str.endsWith(\"bcd\", ignoreCase = true) is ${str.endsWith("bcd", ignoreCase = true)}") // false
//sampleEnd
}
Returns true
if this string ends with the specified suffix.
Since Kotlin
1.8Parameters
the suffix with which this string should end with.
the flag indicating if the string characters should be compared with the suffix characters in a case-insensitive manner; by default, comparison is case-sensitive.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val str = "abcde"
println("str.endsWith(\"cde\") is ${str.endsWith("cde")}") // true
println("str.endsWith(\"CDE\") is ${str.endsWith("CDE")}") // false
println("str.endsWith(\"bcd\") is ${str.endsWith("bcd")}") // false
println("str.endsWith(\"_abcde\") is ${str.endsWith("_abcde")}") // false
//sampleEnd
}
import kotlin.test.*
fun main() {
//sampleStart
val str = "abcde"
println("str.endsWith(\"cde\", ignoreCase = true) is ${str.endsWith("cde", ignoreCase = true)}") // true
println("str.endsWith(\"CDE\", ignoreCase = true) is ${str.endsWith("CDE", ignoreCase = true)}") // true
println("str.endsWith(\"bcd\", ignoreCase = true) is ${str.endsWith("bcd", ignoreCase = true)}") // false
//sampleEnd
}
Returns true
if this string ends with the specified suffix.
Since Kotlin
1.8Parameters
the suffix with which this string should end with.
the flag indicating if the string characters should be compared with the suffix characters in a case-insensitive manner; by default, comparison is case-sensitive.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val str = "abcde"
println("str.endsWith(\"cde\") is ${str.endsWith("cde")}") // true
println("str.endsWith(\"CDE\") is ${str.endsWith("CDE")}") // false
println("str.endsWith(\"bcd\") is ${str.endsWith("bcd")}") // false
println("str.endsWith(\"_abcde\") is ${str.endsWith("_abcde")}") // false
//sampleEnd
}
import kotlin.test.*
fun main() {
//sampleStart
val str = "abcde"
println("str.endsWith(\"cde\", ignoreCase = true) is ${str.endsWith("cde", ignoreCase = true)}") // true
println("str.endsWith(\"CDE\", ignoreCase = true) is ${str.endsWith("CDE", ignoreCase = true)}") // true
println("str.endsWith(\"bcd\", ignoreCase = true) is ${str.endsWith("bcd", ignoreCase = true)}") // false
//sampleEnd
}