From: Jeff Smick Date: 2005-12-02T11:05:44+09:00 Subject: Re: Labelled text file parsing... -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 An easier way to do this might be to use YAML (http://www.yaml.org) which is built into Ruby now. Though, if you'd like this to be more of a project some very simple RegEx work and running through the text line by line wouldn't be too difficult. On Dec 1, 2005, at 5:57 PM, CBlair1986 wrote: > Hi. What I'd like to do is to take a file like so: > --- > Apple > Color: Red > Peel: Yes > Has Core: Yes > > Orange > Color: Orange > Peel: Yes > Has Core: No > --- > and go through it, line by line, assigning the 'Apple' and 'Orange' > lines to a name attribute on different hashes, and then using the name > before the colons such as 'Color' and 'Peel' as keys for the > respective > values. > > I'm just asking for a bit of help and guidance, as I'm still not very > keen on using regular expressions that comfortably and all. > > Thanks to anyone who helps! > > -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (Darwin) iD8DBQFDj6vuG9xIoXK+giARAqZWAKDS2jBxdT7uZirjCwY9fDn2kUaTCgCfZoch VE2fdfkPtrL1k1JOnR3JSis= =9VvV -----END PGP SIGNATURE-----