I making some server reguests and the server reply me with a string that has a lot of spaces in front of the string. the string is USERNAME EXIST
I know how to use this:
String.prototype.killWhiteSpace = function() {
return this.replace(/\s/g, '');};
String.prototype.reduceWhiteSpace = function() {
return this.replace(/\s+/g, ' ');};
but the first the first answer me USERNAMEEXISTS and the second on " USERNAME EXIST"(with one space in front of the string). Is there any way to kill all white spaces before and after the string?