• 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: String manip: from AppleScript to shell
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: String manip: from AppleScript to shell


  • Subject: Re: String manip: from AppleScript to shell
  • From: Philippe GRUCHET <email@hidden>
  • Date: Wed, 29 Jan 2003 19:51:41 +0100

I wrote:

-- string manipulation: swaps two words (here, space separated)

set {aString, text item delimiters} to {"Apple Script", space}
aString's text item 2 & space & aString's text item 1
--> "Script Apple"

set aString to "Apple Script"
do shell script "perl -e 'print(join \" \", reverse split /\\s+/, \""
& aString & "\");'"
--> "Script Apple"

From: Michelle Steiner <email@hidden>

In straight applescript:

set aString to "Apple Script"
set {tid, text item delimiters} to {text item delimiters, space}
set aString to (reverse of text items of aString) as text
set text item delimiters to tid
aString

--> "Script Apple"


Theme & variations ;)

Just a bit shortened? (I like that :-)
In 3 lines instead of 5 (Fibonaccian reduction):

set {aString, tid, text item delimiters} to {"Apple Script", text item delimiters, space}
set {aString, text item delimiters} to {(reverse of aString's text items) as text, tid}
aString

--> "Script Apple"


Kind regards,
Philippe Gruchet/SVM Mac
VNU Publications France
http://svmmac.vnunet.fr
_______________________________________________
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.

  • Prev by Date: Re: applescript-users digest, Vol 3 #1296 - 17 msgs
  • Next by Date: Re: Run a Macro in MS Excel (v.X)
  • Previous by thread: Re: String manip: from AppleScript to shell
  • Next by thread: Mail.app Script
  • Index(es):
    • Date
    • Thread