Javascript String trimEnd(s)
String.prototype.trimEnd = function(s) { return this.replace(new RegExp(s + "+$", "gm"), "") }