From: Joel VanderWerf Date: 2006-05-19T03:41:28+09:00 Subject: Re: String#nstrip ? Daniel Berger wrote: > Hi all, > > When using the Win32API package, I often have to resort to this idiom to > get a string out of a buffer: > > string.split(0.chr).first Why won't slice do the trick? irb(main):001:0> s = "hello\0\0\0\0" => "hello\000\000\000\000" irb(main):002:0> s[/^.*?(?=\0)/] => "hello" -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407