> pattern = re.compile(r"^\s*A\s*{.*}\s*", re.MULTILINE | re.DOTALL) correction pattern = re.compile(r"^\s*A\s*{.*?}\s*", re.MULTILINE | re.DOTALL) I forgot to make it non gready :)