import re with open ("ChangeLog", "r") as f: with open ("ChangeLog.multiboot", "w") as fw: entry = "" for line in f: if re.match ("(199|200)[0-9]", line) : if re.search ("\* (docs/boot.S|docs/help2man|docs/kernel.c|docs/Makefile.am|docs/multiboot.h|docs/multiboot.texi|docs/src2texi|AUTHORS|autogen.sh|configure.ac|COPYING|INSTALL|Makefile.am|NEWS|README)", entry): fw.write (entry) entry = "" entry = entry + line