replaceFirst

inline fun CharSequence.replaceFirst(regex: Regex, replacement: String): String(source)

Replaces the first occurrence of the given regular expression regex in this char sequence with specified replacement expression.

Since Kotlin

1.0

Parameters

replacement

A replacement expression that can include substitutions. See Regex.replaceFirst for details.


expect fun String.replaceFirst(oldChar: Char, newChar: Char, ignoreCase: Boolean = false): String(source)

Returns a new string with the first occurrence of oldChar replaced with newChar.

Since Kotlin

1.0

expect fun String.replaceFirst(oldValue: String, newValue: String, ignoreCase: Boolean = false): String(source)

Returns a new string obtained by replacing the first occurrence of the oldValue substring in this string with the specified newValue string.

Since Kotlin

1.0
actual fun String.replaceFirst(oldChar: Char, newChar: Char, ignoreCase: Boolean = false): String(source)
actual fun String.replaceFirst(oldValue: String, newValue: String, ignoreCase: Boolean = false): String(source)

Since Kotlin

1.1
actual fun String.replaceFirst(oldChar: Char, newChar: Char, ignoreCase: Boolean = false): String(source)

Returns a new string with the first occurrence of oldChar replaced with newChar.

Since Kotlin

1.0

actual fun String.replaceFirst(oldValue: String, newValue: String, ignoreCase: Boolean = false): String(source)

Returns a new string obtained by replacing the first occurrence of the oldValue substring in this string with the specified newValue string.

Since Kotlin

1.0
actual fun String.replaceFirst(oldChar: Char, newChar: Char, ignoreCase: Boolean = false): String(source)

Returns a new string with the first occurrence of oldChar replaced with newChar.

Since Kotlin

1.3

actual fun String.replaceFirst(oldValue: String, newValue: String, ignoreCase: Boolean = false): String(source)

Returns a new string obtained by replacing the first occurrence of the oldValue substring in this string with the specified newValue string.

Since Kotlin

1.3