How to remove white spaces from a string 0
Dec19
Today at work, I happened to write a function that removes white spaces from a string. After trying different ways using: loops, array indexer, or regex, I came up with the shortest way using regular expression to share with you:
var str = ” — This is %$# ‘\’ a test string ha hee hhhoo 1 22 33 “; str = str.replace(/\s/g, ”); // str is now –Thisis%$#”ateststringhaheehhhoo12233









subscribe to comments RSS
There are no comments for this post