------ art_470_17234674.1320992103188
Content-Type: multipart/alternative;
boundary --- art_471_21317169.1320992103189"
------ art_471_21317169.1320992103189
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
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 \*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:
number atch[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.
------ art_471_21317169.1320992103189
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
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.<br><br>Okay if you have done that, let's say you have read the file into a variable called `text`.<br><br>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.<br><br>For example the number appears like so:<br><br><pre> *Number :* 0085252<br></pre><br>You could get this information by matching against the *Number :* part so as to find the rest. So something like<br><br> match = /\*Number\s*:\*(\d+)/.match(text)<br><br>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.<br><br>Because of the (\d+) we have capture the digits in the first match element, so:<br> <br> number = match[1]<br><br>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.<br><br>And have fun.t's a like a puzzle, not a chore.<br><br>
------ art_471_21317169.1320992103189--
------ art_470_17234674.1320992103188--