I am parsing text that has a heading and then data that applies to that heading. I need to break each data field into groups, and have the heading also apply to those groups. Here's an example:
(Update: The text below has been updated to better reflect it's current layout, and to indicate an annotation.)
Heading 1 Heading 2 Heading 3 (Group 1) data1 data2 data3 data4 data5 (Group 2) data1 data2 data3 data4 data5 (Group 3) data1 data2 data3 data4 data5 ** The headers become different values here *** (this is not part of the data) NewHeading 1 NewHeading 2 NewHeading 3 (Group 4) data1 data2 data3 data4 data5 (Group 5) data1 data2 data3 data4 data5 **etc
The output should be like this:
(Group 1) Heading1 Heading2 Heading3 data1 data2 data3 data4 data5 (Group 2) Heading1 Heading2 Heading3 data1 data2 data3 data4 data5 (Group 3) Heading1 Heading2 Heading3 data1 data2 data3 data4 data5 (Group 4) NewHeading1 NewHeading2 NewHeading3 data1 data2 data3 data4 data5 (Group 5) NewHeading1 NewHeading2 NewHeading3 data1 data2 data3 data4 data5
The fields marked (Group 1-5) are just labels for the line, they are not meant to be part of the returned set. The Headings changing to "NewHeading" is merely to indicate that the header values have changed and should be applied to the data that follows it.
I've done a bit of reading over the past couple of hours looking for what this is called, but I haven't had any luck. Any ideas? This is for the .Net regex engine.
Update: Annotations added, and showed that the headers change over the file. I have also done some research and believe I can accomplish something almost as easy by having two patterns. One for the headers, and one for the data. Then I can compare the header and data match index (ie: where it is found in the file) to each other and combine them that way.