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

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)