I'd like to use regular expressions to extract information out of some chat logs. The format of the strings being parsed are 03:22:32 PM <b>blcArmadillo</b>
. I used the python type() command to find that the variable messages is a callable-iterator. My question is how do I most efficiently navigate through a callable-iterator? Are they like arrays where you can just use an index? The only way I could find to "extract" the data was to loop through the returned values and add them to a list as shown in the code snipet below.
times = []
messages = re.compile(r'(?P<time>..:..:.. ..).*?<b>(?P<usrname>.*?):</b>').finditer(search)
for result in messages:
times.append(result.group('time'))
Is there a better more effiecnt way of doing this? Thanks for the help.