replace
fun CharSequence.replace(
regex: Regex,
replacement: String
): String
Returns a new string obtained by replacing each substring of this char sequence that matches the given regular expression with the given replacement.
The replacement can consist of any combination of literal text and $-substitutions. To treat the replacement string literally escape it with the kotlin.text.Regex.Companion.escapeReplacement method.
inline fun CharSequence.replace(
regex: Regex,
noinline transform: (MatchResult) -> CharSequence
): String
Returns a new string obtained by replacing each substring of this char sequence that matches the given regular expression with the result of the given function transform that takes MatchResult and returns a string to be used as a replacement for that match.