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



Hey there, on Mon Jul 25 18:10:30 2011, Zavatone, Alex wrote the following interesting missive:

Hi.  I've got a little not so elegant script to trim spaces from the beginning of a line.  It handles if the whole line is full of spaces, but I was wondering if anyone out there has anything faster and is willing to share.

set source to "          1234               r"
set trimmed to TrimSpacesFromStartOfLine(source)

on TrimSpacesFromStartOfLine(myText)
if length of myText > 1 then
repeat
display dialog myText
if character 1 of myText is " " then
set myText to text 2 through end of myText
else
return myText
exit repeat
end if
end repeat
end if
end TrimSpacesFromStartOfLine
trimmed

-- 
"Better Plan B than plan d & c."


 _______________________________________________
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>)



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.