# HG changeset patch # User Sylvain Thénault # Date 1296252688 -3600 # Node ID c1fdf590712f27c358d2c5d6b3e46cc314dc98ab # Parent c41336a682edb37d052c58142d5a82231c875e9a [js lib] new string.rstrip method diff -r c41336a682ed -r c1fdf590712f web/data/cubicweb.python.js --- a/web/data/cubicweb.python.js Fri Jan 28 16:19:22 2011 +0100 +++ b/web/data/cubicweb.python.js Fri Jan 28 23:11:28 2011 +0100 @@ -188,6 +188,16 @@ return this.replace(/^\s*(.*?)\s*$/, "$1"); }; +/** + * .. function:: String.prototype.rstrip() + * + * python-like rstrip method for js strings + */ +String.prototype.rstrip = function(str) { + if (!str) { str = '\s' ; } + return this.replace(new RegExp('^(.*?)' + str + '*$'), "$1"); +}; + // ========= class factories ========= // /**