On 5/1/10, Hadmut Danisch <hadmut / danisch.de> wrote: > I've checked several ruby books, but did not find a command for the > unpack functions (String->Array) to convert a > C-style 0-terminated String of previously unknown length into a ruby > string. > > E.g. parse someting like apple\0orange\0banana\0 This question would have been better suited to ruby-talk, rather than ruby-core. The unpack string "Z*Z*Z*" will unpack that particular input: > "apple\0orange\0banana\0".unpack("Z*Z*Z*") => ["apple", "orange", "banana"] This assumes that input always contains just 3 strings. If you have more they will be ignored. Not sure if that's what you want, but HTH.