From: nobu.nokada@... Date: 2003-04-11T22:13:08+09:00 Subject: Re: 'Z' and 'A' String#unpack question Hi, At Fri, 11 Apr 2003 21:51:58 +0900, wrote: > i wondered that 'Z' or 'A' parameters in String#unpack to return a > string with characters that follow the first null character removed . 'Z' removes trailing NUL characters. $ ruby -e 'p "this is my test\000please remove this\0\0\0".unpack("Z*")' ["this is my test\000please remove this"] > i think this is useful for extracting C null-terminated string that has > not been filled with null characters. string.sub(/\0.*/m, '') or string[/\A[^\0]*/] -- Nobu Nakada