Javascript String chomp(separator)
String.prototype.chomp = function(separator) { var extra = separator ? separator + "|" : ""; return this.replace(new RegExp("("+extra+"\\r|\\n|\\r\\n)*$"), ""); }