Created
June 13, 2020 16:32
-
-
Save ajaypro/d82b74dcd1848a1610efca55533c6af5 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
// replace whitespaces in string | |
fun main() { | |
var str = "T his is b ett er." | |
var pharse = str.replace("\\s".toRegex(),"") | |
println(pharse) | |
} | |
We've used regular expression \\s that finds all white space characters (tabs, spaces, new line character, etc.) | |
in the string. Then, we replace it with "" (empty string literal). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment