W3cubDocs

/Kotlin

substring

Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
fun String.substring(startIndex: Int): String

Returns a substring of this string that starts at the specified startIndex and continues to the end of the string.

Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
fun String.substring(startIndex: Int, endIndex: Int): String

Returns the substring of this string starting at the startIndex and ending right before the endIndex.

Parameters

startIndex - the start index (inclusive).

endIndex - the end index (exclusive).

Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
fun String.substring(range: IntRange): String

Returns a substring specified by the given range of indices.

Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
fun CharSequence.substring(
    startIndex: Int, 
    endIndex: Int = length
): String

Returns a substring of chars from a range of this char sequence starting at the startIndex and ending right before the endIndex.

Parameters

startIndex - the start index (inclusive).

endIndex - the end index (exclusive). If not specified, the length of the char sequence is used.

Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
fun CharSequence.substring(range: IntRange): String

Returns a substring of chars at indices from the specified range of this char sequence.

© 2010–2019 JetBrains s.r.o.
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/substring.html