Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
val address = "123 Main Street".replaceAll("[0-9]", "x")
println(address) // xxx Main Street
val regex2 = "[0-9]".r
val newAddress = regex2.replaceAllIn("123 Main Street", "x")
println(newAddress) // xxx Main Street
val result2 = "123".replaceFirst("[0-9]", "x")
println(result2) // x23
val regex3 = "H".r
val result3 = regex3.replaceFirstIn("Hello world", "J")
println(result3) // Jello world
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment