Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: joining strings

From: dhsunanda:gmai:l at: 27-Jul-2009 16:57

> What is the best way to join a block into a string with a separator?
The best way may be a loop as it permits you to handle special cases as they arise. With your test example, this will work: b: ["a" "b" "1" "2"] replace/all form b " " "-" == "a-b-1-2" But that will fail if any of your strings have embedded spaces. *** This works better with embedded spaces.... b: ["a z" " b" "1" "2"] replace/all replace/all mold/only b { "} "-" {"} "" == "a z- b-1-2" ....But it should not be hard to find test cases that break it -- eg if your strings also have embedded quotes: b: [{a z "} " b" "1" "2"] Sunanda,