Node.js examples for String:Trim
RTrim() - returns a string with Right blank spaces removed
function RTrim(str) { var whitespace = new String(" \t\n\r"); var s = new String(str); if (whitespace.indexOf(s.charAt(s.length-1)) != -1) { var i = s.length - 1; while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1) { i--;//from w w w .j a va2 s . com } s = s.substring(0, i+1); } return s; }