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
On 22/04/2008, braudes <[EMAIL PROTECTED]> 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() {
> va
On 22/04/2008, Richard Quadling <[EMAIL PROTECTED]> wrote:
> On 22/04/2008, braudes <[EMAIL PROTECTED]> 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*)*)/;
>
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:
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.r