Now, if we are talking about convenience functions, what I would really like to see is a class that wraps a string that allows matches to be done incrementally, where each successful match consumes the head of the string, leaving the remainder of the string for the next match.
This can be done very efficiently since the regex functions all take a start-index parameter. Essentially, the wrapper class would update the start index each time a successful match was performed.
So something like:
stream = MatchStream(string) while 1: m = stream.match(combined_re) # m is a match object # Do something with m
Or even an iterator over matches (this assumes that you want to use the same regex each time, which may not be the case for a parser):
stream = MatchStream(string) for m in stream.match(combined_re): # m is a match object # Do something with m
You might be interested in the undocumented re.Scanner class :) Georg -- Thus spake the Lord: Thou shalt indent with four spaces. No more, no less. Four shall be the number of spaces thou shalt indent, and the number of thy indenting shall be four. Eight shalt thou not indent, nor either indent thou two, excepting that thou then proceed to four. Tabs are right out.