Hi, I'm newbie to ruby, but I try searching a lot for my problem...
I need to extract from an enormous text file, in natural language, for
two separated element in the same line and put them in a new file.
Example:
IIS - IPSIASAR L. DA VINCI (XN____01) - Responsabile: ENRICO FLAIANO
VIA MONTE S. ROCCO, 15 PINETA SIGNORINI - 67100 L'AQUILA (AQ) - tel.
0862 22112 - fax. 0862 22300 email : ipias_aq@yahoo.it -
url:http://www.istitutoleonardodavinciaq.191.it
I need to extract the code (XN____01) and the relative email
"ipias_aq@yahoo.it ", put them in a CSV file or a sort of.
May I do this in ruby?
Thank's very much for any help and so sorry for my bad english...
···
--
Posted via http://www.ruby-forum.com/ .
Luis1
(Luis)
18 May 2010 11:37
2
You can do it using a capture group:
http://ruby-doc.org/docs/ruby-doc-bundle/Manual/man-1.4/syntax.html#regexp
and examples here: Regex Tutorial - Parentheses for Grouping and Capturing
···
On Tue, May 18, 2010 at 7:39 AM, Andrea Carmisciano <andrea.carmisciano@gmail.com> wrote:
Hi, I'm newbie to ruby, but I try searching a lot for my problem...
I need to extract from an enormous text file, in natural language, for
two separated element in the same line and put them in a new file.
Example:
IIS - IPSIASAR L. DA VINCI (XN____01) - Responsabile: ENRICO FLAIANO
VIA MONTE S. ROCCO, 15 PINETA SIGNORINI - 67100 L'AQUILA (AQ) - tel.
0862 22112 - fax. 0862 22300 email : ipias_aq@yahoo.it -
url:http://www.istitutoleonardodavinciaq.191.it
I need to extract the code (XN____01) and the relative email
"ipias_aq@yahoo.it", put them in a CSV file or a sort of.
May I do this in ruby?
--
Luis Parravicini
http://ktulu.com.ar/blog/
Spec_Ex
(Spec Ex)
18 May 2010 17:40
4
Andrea Carmisciano wrote:
Luis Parravicini wrote:
I need to extract the code (XN____01) and the relative email
"ipias_aq@yahoo.it", put them in a CSV file or a sort of.
May I do this in ruby?
You can do it using a capture group:
Ruby Syntax
and examples here: Regex Tutorial - Parentheses for Grouping and Capturing
Thank you, but 'couse I'm quiet stupid, can you write me a pseudo-coded
example? For the regex part, not the file open/write part.
Thank's again!
Maybe this can help:
···
On Tue, May 18, 2010 at 7:39 AM, Andrea Carmisciano >> <andrea.carmisciano@gmail.com> wrote:
--
Posted via http://www.ruby-forum.com/\ .
It's a bit difficult to guess which parts of your line are stable and
which not, i.e. how to build the regexp. Can you post, say 5,
different lines so we can recognize the pattern?
Kind regards
robert
···
2010/5/18 Andrea Carmisciano <andrea.carmisciano@gmail.com>:
Luis Parravicini wrote:
On Tue, May 18, 2010 at 7:39 AM, Andrea Carmisciano >> <andrea.carmisciano@gmail.com> wrote:
I need to extract the code (XN____01) and the relative email
"ipias_aq@yahoo.it", put them in a CSV file or a sort of.
May I do this in ruby?
You can do it using a capture group:
Ruby Syntax
and examples here: Regex Tutorial - Parentheses for Grouping and Capturing
Thank you, but 'couse I'm quiet stupid, can you write me a pseudo-coded
example? For the regex part, not the file open/write part.
--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/