Parsing text



Hey all,

I have a file where I need to parse information from. The format of the
first line is something like this:

">ruby ruby |ruby|ruby ruby|text_i_want| test test"

I was thinking converting this line into an array, using the .split(//)
and keeping count of the pipe("|") character so that when it reaches the
3rd one, it reads the characters up till the 4th pipe(all in a do
iterator. So in essence, I would want to extract "text_i_want". When i
tried this method, I got stuck. Any ideas on how to move forward? Or an
easier solution than this? Thanks!

--
Posted via http://www.ruby-forum.com/.

.



Relevant Pages

  • Re: Parsing text
    ... I have a file where I need to parse information from. ... The format of the ... I was thinking converting this line into an array, ...
    (comp.lang.ruby)
  • Prevent Blank Records being written. Need Help.
    ... Secondary record format is as follows: ... character text field, ... no input mask requirement ... allow zero length = yes. ...
    (microsoft.public.access.forms)
  • RE: Prevent Blank Records being written. Need Help.
    ... Secondary record format is as follows: ... > no input mask requirement ... > 30 character text field, ... > allow zero length = yes. ...
    (microsoft.public.access.forms)
  • Re: newbie question for reading input file
    ... Declarations are *VERY* important. ... feature is using a real variable to store character values. ... You have to use an explicit format with an appropriate "A" edit ... unused data edit descriptors at the end of the format are ignored, ...
    (comp.lang.fortran)
  • Re: txt-file is in ANSI format or OEM Character format.
    ... Try 2 and 3 above changing formating to a different Font. ... This file I open in UltraEdit and change ANSI to OEM and close ... The older printers have a smaller character set it ... Character format. ...
    (microsoft.public.excel.programming)