Question : remove white space
Answered by : akash-kumar-h078bu9hbq9s
//Extenion function
fun String.removeWhitespaces() = replace(" ", "")
// Uses
var str = "This is an example text".removeWhitespaces()
println(str)
Source : https://stackoverflow.com/questions/60028103/how-to-remove-all-the-whitespaces-from-a-string-in-kotlin | Last Update : Wed, 04 Aug 21
Question : Remove White Space At Sides
Answered by : eric-tam
$x = " abc ";
print(trim($x));
There are three versions of trim().
trim(): trims white space on both ends
rtrim(): trims white space on the right end
ltrim(): trims white space on the left end
Note that trim() does not remove white space in the middle of the string.
Source : | Last Update : Sun, 10 Jul 22
Question : remove white space from start and end
Answered by : smiling-skunk-96ktnmjgs6m9
let hello = " Hello, World! ";
let wsRegex = /^\s+|\s+$/g; // Change this line
let result = hello.replace(wsRegex, ""); // Change this line
Source : https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-remove-whitespace-from-start-and-end/301362 | Last Update : Sun, 24 Apr 22
Question : remove white space from begining and end of string
Answered by : ngoc-chau
var hello = ' Hello there! ';
// returns "Hello there!"
hello.trim();
Source : https://gomakethings.com/how-to-remove-white-space-from-the-beginning-or-end-of-a-string-with-vanilla-js/ | Last Update : Thu, 14 Apr 22