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: "Mark J. Reed" <email@hidden>
- Date: Mon, 25 Jul 2011 14:17:05 -0400
Well, if you don't mind collapsing any other whitespace down to a single space while you're at it:
set text item delimiters to space
words 1 through end of myText as text
On Mon, Jul 25, 2011 at 2:10 PM, Zavatone, Alex
<email@hidden> wrote:
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.
TIA, Alex Zavatone
Here's mine:
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
This email message and any attachments are for the sole use of the intended recipient(s) and may contain information that is proprietary to U.S. Foodservice, Inc and/or its subsidiaries or otherwise confidential or legally privileged. If you have received this message in error, please notify the sender by reply, and delete all copies of this message and any attachments. If you are the intended recipient you may use the information contained in this message and any files attached to this message only as authorized by U.S. Foodservice. Files attached to this message may only be transmitted using secure systems and appropriate means of encryption, and must be secured using the same level password and security protection with which the file was provided to you. Any unauthorized use, dissemination or disclosure of this message or it's attachments is strictly prohibited.
_______________________________________________
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
--
Mark J. Reed <
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