| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
Le 26 sept. 2006 à 00:14, T&B a écrit : And now a shorter one using some complementary handlers. property sticky : ASCII character (202) set textBlock to "item1 item2 'item 3' [item 4]" set delimiter to " " set quotePairList to {{quote, quote}, {"'", "'"}, {"[", "]"}} -- set textBlock to normalize(textBlock, quotePairList) set liste to spaces2space(textBlock) on spaces2space(T) repeat while T contains " " set T to my remplace(" ", space, T) end repeat -- here, TID is space set lt to text items of T set AppleScript's text item delimiters to "" return lt -- TID is "" end spaces2space on normalize(T, L) repeat with ba in L set {b, a} to ba if b is in T then set lt to my decoupe(T, b) if b = a then repeat with i from 2 to ((count of lt) - 1) by 2 if lt's item i contains space then set lt's item i to my remplace(space, sticky, lt's item i) end repeat -- i else repeat with i from 2 to (count of lt) if lt's item i contains a then set lt2 to my decoupe(lt's item i, a) if lt2's item 1 contains space then set lt2's item 1 to my remplace(space, sticky, lt2's item 1) set lt's item i to my recolle(lt2, "") end if end repeat -- i end if -- b=a set T to my recolle(lt, "") end if -- b is in T end repeat -- ba return T -- TID is "" end normalize on remplace(b, a, T) set AppleScript's text item delimiters to b set {L, AppleScript's text item delimiters} to {text items of T, a} return L as text -- TID is a end remplace on decoupe(T, d) set AppleScript's text item delimiters to d return text items of T -- TID is d end decoupe on recolle(L, d) set AppleScript's text item delimiters to d return L as text -- TID is d end recolle Yvan KOENIG |
_______________________________________________ Do not post admin requests to the list. They will be ignored. Applescript-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/applescript-users/email@hidden This email sent to email@hidden
| References: | |
| >Parsing quoted text (From: T&B <email@hidden>) | |
| >Re: Parsing quoted text (From: Yvan KOENIG <email@hidden>) | |
| >Re: Parsing quoted text (From: T&B <email@hidden>) |
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2007 Apple Inc. All rights reserved.