replaceOrFail

fun String.replaceOrFail(oldValue: String, replacement: String): String(source)

Asserts that the receiver string changes after calling String.replace with oldValue and replacement.

Return

the new string after replacement

Parameters

oldValue

the old value to be replaced

replacement

the new value to replace the old value

Throws

if the string does not change after replacement


fun String.replaceOrFail(regex: Regex, replacement: String): String(source)

Asserts that the receiver string changes after calling String.replace with regex and replacement.

Return

the new string after replacement

Parameters

regex

the regular expression to be replaced

replacement

the new value to replace the matched regular expression

Throws

if the string does not change after replacement