> What I first though was if there was possible to make a filter such as: > > Apples (apples) > (ducks) Ducks > (butter) g butter
Try something like: import re text = """> Some text that can span some lines. Apples 34 56 Ducks Some more text. """ filters = {"apples": re.compile(r"Apples\s+(\d+)"), "ducks": re.compile(r"(\d+)\s+Ducks"), "butter": re.compile(r"([0-9.]+)\s+g\s+butter")} out = [] for k,v in filters.iteritems(): matches = v.findall(text) for match in matches: out.append((k, match)) print out -- http://mail.python.org/mailman/listinfo/python-list