in reply to Re^2: Parse a block of text
in thread Parse a block of text

Your problem is that you're reading a line at a time. This means you don't have the information you need until it's too late. You'd have to switch to reading two lines at a time and that's just silly. But, you'd use a positive lookahead, in-string line anchors, and the sm modifiers.

My criteria for good software:
  1. Does it work?
  2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?