• 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: Parsing quoted text
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Parsing quoted text


  • Subject: Re: Parsing quoted text
  • From: Yvan KOENIG <email@hidden>
  • Date: Tue, 26 Sep 2006 08:42:52 +0200


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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Parsing quoted text
      • From: T&B <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>)

  • Prev by Date: Re: Parsing quoted text
  • Next by Date: Re: Parsing quoted text
  • Previous by thread: Re: Parsing quoted text
  • Next by thread: Re: Parsing quoted text
  • Index(es):
    • Date
    • Thread