如何使用 Kotlin 中的其他内容替换字符串的许多部分 .replace()
比如我们只需要替换一个词就可以做到
fun main(args: Array<String>) {
var w_text = "welcome his name is John"
println("${w_text.replace("his","here")}")
}
Run Code Online (Sandbox Code Playgroud)
结果将是“欢迎来到这里,名字是约翰”。
最后我们需要的结果是“欢迎这里的名字是 alles”
通过将他的to here和john替换为alles使用 .replace()
kotlin ×1