[Prototype-core] String methods

2008-04-22 Thread braudes
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

[Prototype-core] Re: String methods

2008-04-22 Thread Richard Quadling
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

[Prototype-core] Re: String methods

2008-04-22 Thread Richard Quadling
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*)*)/; >

[Prototype-core] Re: String methods

2008-04-22 Thread Tom Gregory
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:

[Prototype-core] Re: String methods

2008-04-22 Thread Ken Snyder
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