> I think regexp is the wrong way to do this.  Since this is a binary
> file format a regexp is unlikely to give you real data.  Scanning
> seems to work out better.  Where did you get this data?

Can you tell me why regular expressions are bad for this? Although the 
text represents binary, its just text at the end of the day. And if i 
know in advance that the binary starts after a :20 and ends before a 
d\d+ is there any reason why
/:20.+?d\d+/ wouldnt work?

I looked at StringScanner but that seems to use regular experssion to 
scan though.

What confuses me re: reg expressions is if I do something like

File.open("some-file", "rb") do |data|
text = data.read
end

text =~ /(.{20})/um
$1
=> "d5:filesd20:\000\006û쥣éñ¥§å㥵

Notice that the result doesnt show 20 characters and it doesnt end with 
the expected " that irb uses to enclose results...whys that?
-- 
Posted via http://www.ruby-forum.com/.