On Thu, 26 Apr 2001, Erich Schubert wrote: > run this line in ruby... > > ["",""].join("/").split("/") > > you get an empty array :-( > > How can i split the string and get an the same result i had before > joining them? > > i had a directory name and got some verry irritating behaviour this > way... > > "/dir".split("/") gives the same result as "/dir/".split("/") :-( > > so "/dir/".split("/").join("/") gives not "/dir/" but "/dir" :-( Use a negative limit on the split to stop it stripping trailing empty fields: irb(main):018:0> "/dir/".split("/") ["", "dir"] irb(main):019:0> "/dir".split("/") ["", "dir"] irb(main):020:0> "/dir/".split("/", -1) ["", "dir", ""] irb(main):021:0> "/dir".split("/", -1) ["", "dir"] irb(main):022:0> "/dir/".split("/", -1).join("/") "/dir/" Hope this helps, Mike -- mike / stok.co.uk | The "`Stok' disclaimers" apply. http://www.stok.co.uk/~mike/ | GPG PGP Key 1024D/059913DA | Fingerprint 0570 71CD 6790 7C28 3D60 stok / colltech.com (CT - work) | 75D2 9EC4 C1C0 0599 13DA