Next: How do I match any string not matched in the preceding rules?, Previous: How can I expand macros in the input?, Up: FAQ [Contents][Index]
One way to do it is to filter the first pass to a temporary file, then process the temporary file on the second pass. You will probably see a performance hit, due to all the disk I/O.
When you need to look ahead far forward like this, it almost always means that the right solution is to build a parse tree of the entire input, then walk it after the parse in order to generate the output. In a sense, this is a two-pass approach, once through the text and once through the parse tree, but the performance hit for the latter is usually an order of magnitude smaller, since everything is already classified, in binary format, and residing in memory.