function trim(str) {
str = str.replace(/^\s+|\s+$/g, '');
for (var i = str.length - 1; i >= 0; i--) {
if (/\S/.test(str.charAt(i))) {
str = str.substring(0, i + 1);
break;
}
}
return str;
}
Sign up here with your email
A personal blog with the collection of self interested topics