Created
January 11, 2015 10:03
-
-
Save shigemk2/ff237e2bbfdfd19c4ac3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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