W3cubDocs

/Kotlin

replaceFirst

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

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

Parameters

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

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

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

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

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

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