In article <120220041122469448%user / unknown.invalid>, Koncept <user / unknown.invalid> wrote: >In article ><XOCWb.33248$TPZ.8375 / twister01.bloor.is.net.cable.rogers.com>, Mike >Stok <mike / stok.co.uk> wrote: > >> One thing that you might consider is that you have a line which looks >> like a CSV data record with { } adound it, so you could use a library >> from the Ruby Application Archive to mangle it after you've trimmed the >> { and }. > >The {} is the result of issuing a command to AppleScript. This is the >way Applescript formats "Lists" or Arrays. > >> >> Alternatively, if the data is "well behaved", you can use a regular >> expression to pick it apart. Using irb (interactive ruby to experiment: >> >> >> result = '{ "robert", "trey", "adrian", "pat" }' >> => "{ \"robert\", \"trey\", \"adrian\", \"pat\" }" >> >> result.scan(/"(.*?)"/).flatten >> => ["robert", "trey", "adrian", "pat"] >> > >Forgive me if I am missing something... > >irb(main):001:0> result = '{ "robert","trey","adrian", "pat" }' >=> "{ \"robert\",\"trey\",\"adrian\", \"pat\" }" > >irb(main):002:0> result.scan(/"(.*?)"/).flatten >=> ["robert", "trey", "adrian", "pat"] > >irb(main):004:0> result.class >=> *String* > >irb(main):005:0> result = ["robert","trey","adrian","pat"] >=> ["robert", "trey", "adrian", "pat"] > >irb(main):006:0> result.class >=> *Array* > >Your solution formatted my string to look like an Array, but the result >still has a class of String. :( irb was just showing what the value of the expression was. If you want to apply the technique then either store the result >> data = '{ "robert","trey","adrian", "pat" }' => "{ \"robert\",\"trey\",\"adrian\", \"pat\" }" >> result = data.scan(/"(.*?)"/).flatten => ["robert", "trey", "adrian", "pat"] >> data.class => String >> result.class => Array or use it immediately e.g. >> data.scan(/"(.*?)"/).flatten.each do |name| ?> puts "got >#{name}<" >> end got >robert< got >trey< got >adrian< got >pat< => ["robert", "trey", "adrian", "pat"] In general ruby methods don't change object being operated upon unless they have a "destructive sounding name" (e.g. Array#delete) or end with a ! (e.g. String#gsub!) Hope this helps, Mike -- mike / stok.co.uk | The "`Stok' disclaimers" apply. http://www.stok.co.uk/~mike/ | GPG PGP Key 1024D/059913DA mike / exegenix.com | Fingerprint 0570 71CD 6790 7C28 3D60 http://www.exegenix.com/ | 75D2 9EC4 C1C0 0599 13DA