• truncsp() for beginnings of strings?

    From art@VERT/FATCATS to All on Tue Nov 17 09:48:22 2009
    Hi all,ããIs there a way to trim whitespaces at the beginning of strings, like truncsp()?ããRegards,ãArt at fatcats dot poorcoding dot comãã| fatcats bbs |ã| + telnet://fatcats.poorcoding.com |ã| + ssh://fatcats.poorcoding.com:2322 |ãã---ã þ Synchronet þ fatcats bbs - http://fatcats.poorcoding.comã
  • From Deuce@VERT/SYNCNIX to art on Tue Nov 17 09:46:29 2009
    Re: truncsp() for beginnings of strings?ã By: art to All on Tue Nov 17 2009 09:48 amãã > Is there a way to trim whitespaces at the beginning of strings, likeã > truncsp()?ããstr=str.replace(/^\s*/, '');ãã--- ãSynchronet - Jump on the Web 0.2 bandwagon!ãã---ã þ Synchronet þ My Brand-New BBS (All the cool SysOps run STOCK!)ã
  • From Tracker1@VERT/TRN to art on Tue Nov 17 22:19:59 2009
    On 11/17/2009 2:48 AM, art wrote:ã> Hi all,ã> ã> Is there a way to trim whitespaces at the beginning of strings, like truncsp()?ãã//include this somewhere...ãString.prototype.trim = function() {ã return this.replace(/^[\s\r\n]+|[\s\r\n]+$/g, '');ã}ãString.prototype.ltrin = function() {ã return this.replace(/^[\s\r\n]+/g, '');ã}ãString.prototype.ltrin = function() {ã return this.replace(/[\s\r\n]+$/g, '');ã}ããnow you can use yourstring.ltrim()ãã-- ãMichael J. Ryan - http://tracker1.info/ãã... B5: Then what kind of head of security would I be if I let people like me ãknow things that I'm not supposed to know? I know what I know because I have ãto know it. And if I don't have to know it, I don't tell me, and I don't let ãanyone else tell me either.ãã---ã þ Synchronet þ Roughneck BBS - telnet://roughneckbbs.com - www.roughneckbbs.comã
  • From art@VERT/FATCATS to Tracker1 on Wed Nov 18 08:53:45 2009
    Re: Re: truncsp() for beginnings of strings?ã By: Tracker1 to art on Tue Nov 17 2009 22:19:59ãã > now you can use yourstring.ltrim()ããThanks Deuce and Tracker1...ããI was hoping I wouldn't need to regexp it and it was provided as part of JSOM,ãhowever I'll likely implement a function as you guys have provided the regexpãfor, thanks.ããRegs,ãArt at fatcats dot poorcoding dot comãã| fatcats bbs |ã| + telnet://fatcats.poorcoding.com |ã| + ssh://fatcats.poorcoding.com:2322 |ãã---ã þ Synchronet þ fatcats bbs - http://fatcats.poorcoding.comã
  • From Tracker1@VERT/TRN to art on Wed Nov 18 04:56:47 2009
    On 11/18/2009 1:53 AM, art wrote:ã>> now you can use yourstring.ltrim()ã> ã> Thanks Deuce and Tracker1...ã> ã> I was hoping I wouldn't need to regexp it and it was provided as part of JSOM,ã> however I'll likely implement a function as you guys have provided the regexpã> for, thanks.ããI have a pretty good set of ObjectModelExtensions for JS if you're interested. ã As it is, they should all work in synchronet. Most of them are for things ãthat are sometimes surprising aren't *IN* JavaScript's language. Though it's ãpretty easy to extend/graft any object/class after the fact.ããI have stuff for some .toFormat overload methods for String and Date. I've ãalso spent a little time trying to get base2 functioning in Synchronet ãproperly, but that's been a bit of an effort. base.js works without much ãtrouble though. Still need to implement a number formatter for ãString.toFormat. It does work with dates as-is ex:ããvar fmt = "This is a string with a date-time of " +ã "{dtm:yyyy-MM-dd HH:mm:ss} " +ã "as well as another property of {prop2}.";ãvar fmt2 = "This uses numbered arguments {0} and {1}";ããvar now = new Date();ãvar ret = fmt.toFormat({ dtm:now, prop2: 6 });ãvar ret2 = fmt2.toFormat(now, 5);ãã-- ãMichael J. Ryan - http://tracker1.info/ãã... FRA #144: There's nothing wrong with charity ... as long as it winds up in ãyour pocket.ãã---ã þ Synchronet þ Roughneck BBS - telnet://roughneckbbs.com - www.roughneckbbs.comã
  • From art@VERT/FATCATS to Tracker1 on Wed Nov 18 13:41:45 2009
    Re: Re: truncsp() for beginnings of strings?ã By: Tracker1 to art on Wed Nov 18 2009 04:56:47ãã > I have a pretty good set of ObjectModelExtensions for JS if you're interesteã > As it is, they should all work in synchronet. Most of them are for thingsããI would be interested in taking a look, if you're happy to provide it. Althoughãthe JS and Synchronet APIs are decent, some stuff like .trim would be veryãuseful.ããRegards,ãArt at fatcats dot poorcoding dot comãã| fatcats bbs |ã| + telnet://fatcats.poorcoding.com |ã| + ssh://fatcats.poorcoding.com:2322 |ãã---ã þ Synchronet þ fatcats bbs - http://fatcats.poorcoding.comã
  • From Deuce@VERT/SYNCNIX to Tracker1 on Wed Nov 18 09:29:46 2009
    Re: Re: truncsp() for beginnings of strings?ã By: Tracker1 to art on Tue Nov 17 2009 10:19 pmãã > return this.replace(/^[\s\r\n]+/g, '');ãã\s includes \r and \n. The g flag is useless since + is greedy by default andãthe match is anchored to the start of the string (unless you want multilines,ãwhich you don't).ããSo just replace(/^\s+/, '');ããAs for the whole string trim function...ãã > return this.replace(/^[\s\r\n]+|[\s\r\n]+$/g, '');ããreplace(/^\s*(.*?)\s*$/, '$1');ããIs a lot better (a single replace, no OR, etc).ãã--- ãSynchronet - Jump on the Web 0.2 bandwagon!ãã---ã þ Synchronet þ My Brand-New BBS (All the cool SysOps run STOCK!)ã
  • From Deuce@VERT/SYNCNIX to art on Wed Nov 18 09:33:17 2009
    Re: Re: truncsp() for beginnings of strings?ã By: art to Tracker1 on Wed Nov 18 2009 08:53 amãã > I was hoping I wouldn't need to regexp it and it was provided as part ofã > JSOM, however I'll likely implement a function as you guys have providedã > the regexp for, thanks.ããWell, you could do it without a regexp, but it would be harder.ãã--- ãSynchronet - Jump on the Web 0.2 bandwagon!ãã---ã þ Synchronet þ My Brand-New BBS (All the cool SysOps run STOCK!)ã
  • From MCMLXXIX@VERT/MDJ to Deuce on Wed Nov 18 13:54:06 2009
    Re: Re: truncsp() for beginnings of strings?ã By: Deuce to art on Wed Nov 18 2009 09:33:17ãã > > I was hoping I wouldn't need to regexp it and it was provided as part ofã > > JSOM, however I'll likely implement a function as you guys have providedã > > the regexp for, thanks.ã >ã > Well, you could do it without a regexp, but it would be harder.ã >ããyou mean like my stupid function in funclib.js? yesssssãã---ã þ Synchronet þ The BRoKEN BuBBLE (MDJ.ATH.CX)ã
  • From art@VERT/FATCATS to Deuce on Thu Nov 19 08:36:46 2009
    Re: Re: truncsp() for beginnings of strings?ã By: Deuce to art on Wed Nov 18 2009 09:33:17ãã > Well, you could do it without a regexp, but it would be harder.ããHey Deuce,ãã... well... regexps are horrid enough... to try to do a regexp withoutãregexps... sounds painful!ããThanks for the regexp pointers in previous reply.ããRegs,ãArt at fatcats dot poorcoding dot comãã| fatcats bbs |ã| + telnet://fatcats.poorcoding.com |ã| + ssh://fatcats.poorcoding.com:2322 |ãã---ã þ Synchronet þ fatcats bbs - http://fatcats.poorcoding.comã
  • From Tracker1@VERT/TRN to art on Sun Nov 29 10:34:40 2009
    On 11/18/2009 6:41 AM, art wrote:ã>> I have a pretty good set of ObjectModelExtensions for JS if you're interesteã>> As it is, they should all work in synchronet. Most of them are for thingsã> ã> I would be interested in taking a look, if you're happy to provide it. Althoughã> the JS and Synchronet APIs are decent, some stuff like .trim would be veryã> useful.ããhttp://www.roughneckbbs.com/download/ObjectModelExtensions.zipãsee last post.ãã-- ãMichael J. Ryan - http://tracker1.info/ãã---ã þ Synchronet þ Roughneck BBS - telnet://roughneckbbs.com - www.roughneckbbs.comã