In Prototype parlance, "trim" is "strip":
http://prototypejs.org/api/string#method-strip
And in response to Richard, instead of writing your own "left", try
"truncate". Many other needs (ltrim, rtrim, right, mid) are already
met with "sub".
TAG
On Apr 22, 2008, at 8:13 AM, braudes wrote:
>
> Hi,
>
> I notice that the String class doesn´t have some simple methods. So, I
> added these:
>
> ltrim: function() {
> var re = /\s*((\S+\s*)*)/;
> return this.replace(re, "$1");
> },
>
> rtrim: function() {
> var re = /((\s*\S+)*)\s*/;
> return this.replace(re, "$1");
> },
>
> trim: function() {
> return this.rtrim().ltrim();
> },
>
> invert: function() {
> var len = this.length;
> var str = "";
> for (var i = len - 1; i > -1 ;i--){
> str += this.charAt(i);
> }
> return str;
> }
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Prototype: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---