Well said.

Unfortunately I cannot provide an actual example.

So here goes:

  1. I have no control over the incoming data. It will effectively be pasted by someone in a <TEXTAREA>.
  2. The data lines may contain sporadic empty lines, which are to be ignored.
  3. There are useless lines and characters before the useful data starts.
  4. There are useless lines and characters after the useful data ends.
  5. The first unique point at which a line can be identified as being useful, is that it start with the characters 'Number:'.
    This identifier (index) is not at the start of the data.
  6. The data can be split into 4 sections:
    1. TOP
      A set of values with no keys. These are always in the same place relative to each other.
      So, in my previous example, you could safely say $result{Name}='Graq';.
      There is only one value per line.

    2. MIDDLE
      A set of key-value pairs seperated by a colon and space /: /.
      Some lines have 2 key-value pairs on them (never more).
      Keys may contain spaces, values may not.
    3. BOTTOM
      1. A set of key-value pairs seperated by a colon and space.
        One key-value pair per line (see below).
      2. A set of values. These values correspond to key-value pair in (i).
        One value per line (see below).
        NB: The first line of (ii) will be on the same line as the last line of (i), seperated by a space.
    4. END
      A single key-value pair (colon and space seperated), where the value may be missing.

Note on lines with multiple key-value pairs:

  1. The TOP and MIDDLE never mix.
  2. MIDDLE values may have multiple entries.
  3. MIDDLE and BOTTOM(i) may overlap.
  4. BOTTOM(i) and BOTTOM(ii) always overlap.
  5. BOTTOM(ii) and END never mix.

Please don't ask why this is :(

<a href="http://www.graq.co.uk">Graq</a>

edited by footpad, ~Tue Dec 4 14:42:09 2001 (GMT)


In reply to Re: Re: More Regular Expressions (text data handling) by graq
in thread More Regular Expressions (text data handling) by graq

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.