From: "Luca (Email)" Date: 2011-12-29T15:56:41+09:00 Subject: I: important qution on ruby ------=_NextPart_000_432E_01CCC5FD.93135FE0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable =20 =20 Da: Intransition [mailto:transfire@gmail.com]=20 Inviato: venerd=EC 11 novembre 2011 07:15 A: ruby-talk ML; ruby-talk-google@googlegroups.com Cc: ruby-talk ML; ruby-talk@ruby-lang.org Oggetto: Re: important qution on ruby =20 Break the problem down. What is given? First a file. So you need to = "read" the "File". Look up `File.read` and read about that. Okay if you have done that, let's say you have read the file into a = variable called `text`. Now you need to extract information from that text. How will you do = this? There a basically two ways: by position or by pattern. So you need to = figure out what about the file is always the same no matter which students = record it is and use that as a guide to locate the other information. For example the number appears like so: *Number :* 20085252 You could get this information by matching against the *Number :* part = so as to find the rest. So something like match =3D /\*Number\s*:\*(\d+)/.match(text) The characters in between the /.../ are a Regular Expression. Look that = up and read about them. Notice we had to use `\` in some places to "escape" characters or to indicate a special type of character, e.g. \d means any digit. Because of the (\d+) we have capture the digits in the first match = element, so: =20 number =3D match[1] Now you should be able to read up on the things I suggested and work out = how to do it for the rest of the information. And have fun. It's a like a puzzle, not a chore. =0D=0A =0D=0A --=0D=0A Caselle da 1GB, trasmetti allegati fino a 3GB e in piu' IMAP, POP3 e SMTP = autenticato? GRATIS solo con Email.it http://www.email.it/f=0D=0A =0D=0A Sponsor:=0D=0A ING DIRECT Conto Arancio. 4,20% per 12 mesi, zero spese, aprilo in due min= uti!=0D=0A Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=3D11921&d=3D29-12=0D=0A ------=_NextPart_000_432E_01CCC5FD.93135FE0--