• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Removing leading and railing blanks
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Removing leading and railing blanks


  • Subject: Re: Removing leading and railing blanks
  • From: Kai <email@hidden>
  • Date: Thu, 27 Feb 2003 04:28:46 +0000

on Wed, 26 Feb 2003 10:06:02 -0800, Michael Terry <email@hidden> wrote:

> On 2/25/03 5:07 PM, "Michael Terry" <email@hidden> wrote:
>
> Oops, my last handler had a bunch of extra stuff it didn't need (thanks,
> "al"). Removing it produces:
>
> on chomp(str)
> set n to str's {text 1 thru word 1, text -1 thru word -1}
> set AppleScript's text item delimiters to space
> set n to {n's front's text items, n's end's text items}
> set n to {n's front's rest's length, n's end's rest's length}
> text ((n's front) + 1) thru -((n's end) + 1) of str
> end chomp
>
> and makes it pretty fast.

Interesting approach, Terry. About the same speed (given the test string
used) as the repeat loops I suggested. (I guess it might turn out faster
than loops if a whole bunch of spaces were added to either end of the
string).

Probably not too critical, but you might lose the odd character if the
string looked more like this:

" ' date '+%B %e, %G ' "
--> " date '+%B %e, %G "

(You may also want to consider resetting the TIDs to avoid potential
problems elsewhere in a larger script.)

Best wishes.

--
Kai
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: RA Connect
  • Next by Date: Re: PLACING AN APP IN THE RIGHT SIDE OF THE DOCK (iJoe)
  • Previous by thread: Re: Removing leading and railing blanks
  • Next by thread: Re: Removing leading and railing blanks
  • Index(es):
    • Date
    • Thread