Another option could be something like this: You can add ids to your regexp, so you can retrive them latter using groupdict. Once you have the ids in place, you can join in a new regexp with the "|" operator which is not greedy, it will stop after the first match.
pattern = (?P<section>re_section)|?P<name>re_section|... Then you can have another structure with the previous id and the actions you want to perform on them. actions = {'section': lambda r: r[18:-5], 'name': lambda r: r[6:-1]), ...} Finally you just need to iterate over the result. In this case the dictionary will have only one pair. result = pattern.search(line) if result: for key,val in result.groupdict().iteritems(): actions[key](val) .... -- Mauro Cáceres
-- http://mail.python.org/mailman/listinfo/python-list