|
instead of looking at a file as a sequence of lines, let's generalize to allow arbitrary regular expressions to mark boundaries between units.
Isn't this the sort of string library function which many languages offer under a name such as "split"? Break a string into fields separated by some (possibly non-trivial) pattern (default usually something like '[ \t]*')?
If so, I would welcome the addition of a split()-like method to the standard string library...it strikes me as one of those 'feature creeps' which would be sufficiently small (given that it could reuse much existing matching code, as you show here) but sufficiently widely and commonly used as to be, well...useful.