Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Trim space chars from start of line
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Trim space chars from start of line



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

References: 
 >Trim space chars from start of line (From: "Zavatone, Alex" <email@hidden>)
 >Re: Trim space chars from start of line (From: KOENIG Yvan <email@hidden>)
 >Re: Trim space chars from start of line (From: Deivy Petrescu <email@hidden>)
 >Re: Trim space chars from start of line (From: "Zavatone, Alex" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.