[js lib] new string.rstrip method stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 28 Jan 2011 23:11:28 +0100
branchstable
changeset 6921 c1fdf590712f
parent 6920 c41336a682ed
child 6922 cb1dd14a768f
[js lib] new string.rstrip method
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 ========= //
 
 /**