From: Eric Hodel Date: 2008-07-06T04:50:33+09:00 Subject: Re: Problem with unpack On Jul 4, 2008, at 08:36 AM, Rafael wrote: > On 3 Jul., 02:52, Eric Hodel wrote: >> the regex you want is: /\0\020\010\0/ >> >> The big piece of code you wrote can be reduced to file.read(512) =~ / >> \0\020\010\0/. There's no need to convert all the text. >> >> Note that there is a bug in your code, it will also match on a half- >> byte: >> >> 00000100 33 32 35 31 02 00 10 00 55 49 14 00 31 2e 32 2e >> XXXXXXXX 33 32 35 30 20 01 00 01 55 49 14 00 31 2e 32 2e >> ^^^^^^^^^^^^ >> >> The regex solution does not have this bug. > > Hi, > > thanks again for your message. You're absolutely right about the > bug ... how stupid of me! > > But regarding the regular expression, shouldn't it be something like / > \x02\x00\x10\x00/ ? Yes! sorry!