Re: Trim space chars from start of line
Re: Trim space chars from start of line
- Subject: Re: Trim space chars from start of line
- From: Deivy Petrescu <email@hidden>
- Date: Mon, 25 Jul 2011 18:16:44 -0400
On Jul 25, 2011, at 17:17 , Zavatone, Alex wrote:
>
> On Jul 25, 2011, at 4:03 PM, Deivy Petrescu wrote:
>
>> (script)
>> set t to " set myText to characters 2 through myLength of myText as string"
>> set t to characters of t
>> if (contents of item 1 of t) = space then repeat while (contents of item 1 of t) is space
>> set t to rest of t
>> end repeat
>> t as string
>> (script)
>>
>
> Wow. That's crazy.
>
> Unfortunately, it fails if the line is all spaces.
I use this script to remove blanks of beginning of a line.
To remove blanks from a text (with paragraphs) then:
set t to " "
set t to characters of t
if (count of t) > 0 then repeat while (contents of item 1 of t) is space
set t to rest of t
if (count of t) = 0 then exit repeat --- if you want to keep the space
--then change =0 to =1
end repeat
t as string
Deivy Petrescu
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden