Java String class replaceAll method missing

You can do this with just replace in Kotlin:

"foo and foo".replace("foo", "bar") // "bar and bar"

Note that the call above replaces the literal strings, if you need a Regex as the first parameter you can do either of the following:

"foo and bar".replace("[abcd]".toRegex(), "x") // "foo xnx xxr"
"foo and bar".replace(Regex("[abcd]"), "x")    // "foo xnx xxr"

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)