How to access multiple group matches?

Christoph Krammer redtiger84 at googlemail.com
Fri Apr 6 16:31:34 CEST 2007


Hello,

I want to use the re module to split a data stream that consists of
several blocks of data. I use the following code:

iter = re.finditer('^(HEADER\n.*)+$', data)

The data variable contains binary data that has the word HEADER in it
in some places and binary data after this word till the next
appearance of header or the end of the file. But if I iterate over
iter, I only get one match and this match only contains one group. How
to access the other matches? Data may contain tens of them.

Thanks in advance,
 Christoph




More information about the Python-list mailing list