Actually, do something like this (no "using distributivity" like in my first message, to get a minimal git diff) def_re = re.compile(r"(\newcommandx|\renewcommandx|\global\long\def)(\[a-zA-Z]+)(.+)") Regards, Neven Sajko