function rtrim(str) { str = str.replace(new RegExp("[" + (" " || "\s") + "]+$", "g"), ""); return str; }