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 17:03:05 -0400
On Jul 25, 2011, at 15:30 , KOENIG Yvan wrote:
>
> Le 25 juil. 2011 à 20:10, Zavatone, Alex a écrit :
>
>> on TrimSpacesFromStartOfLine(myText)
>> set myLength to the length of myText
>> set myChar to character 1 of myText
>>
>> repeat while (myChar = " ")
>> if myLength > 1 then
>> set myText to characters 2 through myLength of myText as string
>> set myLength to the length of myText
>> set myChar to character 1 of myText
>> else
>> set myText to ""
>> set myChar to ""
>> end if
>> end repeat
>>
>> return myText
>> end TrimSpacesFromStartOfLine
>
>
> Here is my stripped version
>
> on TrimSpacesFromStartOfLine(myText)
>
> repeat while (first character of myText = " ")
> if myText > space then
> set myText to characters 2 through -1 of myText as string
> else
> set myText to ""
> exit repeat
> end if
> end repeat
>
> return myText
> end TrimSpacesFromStartOfLine
>
> my TrimSpacesFromStartOfLine(" just for see.")
>
> Yvan KOENIG (VALLAURIS, France) lundi 25 juillet 2011 21:29:39
>
(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)
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