substring

Returns a substring specified by the given range of indices.

Since Kotlin

1.0

inline fun CharSequence.substring(startIndex: Int, endIndex: Int = length): String(source)

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

Since Kotlin

1.0

Parameters

startIndex

the start index (inclusive).

endIndex

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


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

Since Kotlin

1.0

expect fun String.substring(startIndex: Int): String(source)
expect fun String.substring(startIndex: Int, endIndex: Int): String(source)

Since Kotlin

1.0
actual inline fun String.substring(startIndex: Int): String(source)
actual inline fun String.substring(startIndex: Int, endIndex: Int): String(source)

Since Kotlin

1.1
actual inline fun String.substring(startIndex: Int): String(source)

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

Since Kotlin

1.0

actual inline fun String.substring(startIndex: Int, endIndex: Int): String(source)

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

Since Kotlin

1.0

Parameters

startIndex

the start index (inclusive).

endIndex

the end index (exclusive).

actual inline fun String.substring(startIndex: Int): String(source)

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

Since Kotlin

1.3

actual inline fun String.substring(startIndex: Int, endIndex: Int): String(source)

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

Since Kotlin

1.3

Parameters

startIndex

the start index (inclusive).

endIndex

the end index (exclusive).