## note: untested, and probably really inefficient ## but you get the idea. $output =~ s/description:.*?(?=RCS file|\Z)/\n/msg;