• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Remove extra spaces from a string
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Remove extra spaces from a string


  • Subject: Re: Remove extra spaces from a string
  • From: Nigel Garvey <email@hidden>
  • Date: Mon, 9 Jun 2003 00:10:33 +0100

Paul Skinner wrote on Sun, 8 Jun 2003 07:32:51 -0400:

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

You don't need to do this at all, Paul, if you use negative indices.

>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}

And don't forget there's such a thing as direct text extraction:

set the end of fileData to {text from text item -4 to text item -2,
text item -1}

or:

set the end of fileData to {text (text item -4) thru (text item -2),
text item -1}

NG
_______________________________________________
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.

  • Follow-Ups:
    • Re: Remove extra spaces from a string
      • From: Paul Skinner <email@hidden>
  • Prev by Date: Re: Strange Bottleneck
  • Next by Date: Re: Remove extra spaces from a string
  • Previous by thread: Re: Remove extra spaces from a string
  • Next by thread: Re: Remove extra spaces from a string
  • Index(es):
    • Date
    • Thread