if match(reg1, line): foo, bar = M.groups() elif match(reg2, line): .. elif match(reg3, line): .. else: ..