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)
Thanks for your efforts. This script seems much better, but still has a few bugs, I think, such as these results:
set textBlock to "item1 item2 'item 3' [item 4]" -- ie your script's test
--> {"item1", "item2", "", "item 3", "item 4"}
But should be:
--> {"item1", "item2", "item 3", "item 4"}
And this test:
set textBlock to "item1"
--> {"i", "t", "e", "m", "1"}
But should be:
--> {"item1"}
and this:
set textBlock to "item1 'item[2]'"
--> {"item1", "item2"}
But should be:
--> {"item1", "item[2]"}