Re: Remove extra spaces from a string
Re: Remove extra spaces from a string
- Subject: Re: Remove extra spaces from a string
- From: Paul Skinner <email@hidden>
- Date: Sun, 8 Jun 2003 07:32:51 -0400
On Sunday, June 8, 2003, at 04:48 AM, John Delacour wrote:
If you must use Applescript, then it's quicker and neater to use
'offset' :
snip
Quicker and neater than either.
set fileData to {}
set s to "-rwx------ 0 286 512 Jun 06 12:36
demo10.log
-rwx------ 0 286 512 Jun 06 12:37 demo11.log
-rwx------ 0 286 512 Jun 06 12:38 demo12.log
-rwx------ 0 286 512 Jun 06 12:39 demo13.log
-rwx------ 0 286 512 Jun 06 12:40 demo14.log"
set s to RemoveCharacterRuns(space, s)
set AppleScript's text item delimiters to " "
repeat with thisLine in paragraphs of s
tell thisLine
set the end of fileData to {(text items 5 thru 7) as text, text item
-1}
end tell
end repeat
fileData
-->{{"Jun 06 12:36", "demo10.log"}, {"Jun 06 12:37", "demo11.log"},
{"Jun 06 12:38", "demo12.log"}, {"Jun 06 12:39", "demo13.log"}, {"Jun
06 12:40", "demo14.log"}}
on RemoveCharacterRuns(char, inputText)
set {previousDelimiter, AppleScript's text item delimiters} to
{AppleScript's text item delimiters, ""}
set characterRun to char & char
repeat while inputText contains characterRun
set AppleScript's text item delimiters to characterRun
set {tempS, AppleScript's text item delimiters} to {text items of
inputText, char}
set inputText to tempS as text
end repeat
set AppleScript's text item delimiters to previousDelimiter
return inputText
end RemoveCharacterRuns
JD,
The perl code you posted returns "Jun 06 12:40, demo14.log". Am I
missing something?
Paul
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.