--nextPart7349955.xA6aG7j4qs
Content-Type: text/plain;
  charsettf-8"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

On Friday 10 August 2007 01:43:13 am Ak 756 wrote:
> I want to find a string in a text file, then read some bytes data after
> the position of this string. Would anybody kindly help to tell me how to
> do?

If this is what you really want, you can do something like:

  READ_BYTES = 16
  my_file_contents = File.open('foo'){|f| f.read }
  my_file_contents =~ /find this string(.{#{READ_BYTES}})/
  my_data = $1

Of course, this is no good for large files. Generally if you're trying to
extract data from a large text file though, you should already know where it
is (constant width records) or you have to parse through everything before
the record you want to get at the one you do (csv, xml?).

If this is for a configuration file or some sort of semi-static storage, I'd
recommend using YAML or Marshal instead of making your own parser.

Cheers!
-- 
Konrad Meyer <konrad / tylerc.org> http://konrad.sobertillnoon.com/

--nextPart7349955.xA6aG7j4qs
Content-Type: application/pgp-signature; name=signature.asc 
Content-Description: This is a digitally signed message part.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)

iD8DBQBGvCtkCHB0oCiR2cwRAv7VAJ9TJuiLAgr0K4ffsz29WyXwnbnOPwCdHALl
7DH6vHJ6ZAfPS0YtiQ9EtscL0
-----END PGP SIGNATURE-----

--nextPart7349955.xA6aG7j4qs--