Re: Tidying a string
Re: Tidying a string
- Subject: Re: Tidying a string
- From: Michelle Steiner <email@hidden>
- Date: Thu, 28 Apr 2005 09:56:38 -0700
On Apr 28, 2005, at 9:42 AM, pete boardman wrote:
Given a text string such as " foo bar foo bar foo bar ",
where there are a variable number of spaces between each word, and 0
or more spaces at both start and end, I'd like to strip all
unnecessary spaces and get "foo bar foo bar foo bar". I can't seem to
get text delimiters working to do this. Is there an easy and fast way?
set foo to " foo bar foo bar foo bar "
set text item delimiters to space
set foo to text items of foo
set foobar to {}
repeat with i from 1 to count of foo
if item i of foo is not "" then copy item i of foo to end of foobar
end repeat
foobar
set foobar to foobar as string
set text item delimiters to ""
set foo to foobar
-- Michelle
--
Support our troops. Bring them home NOW!
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden