use strict; while(){ ~s/copyright\s+(\d+)-(\d+),\s+(\d+)/copyright $1-$3/i; print; } __DATA__ Given a string like "copyright 1990-2000, 2001. All rights reserved ... OUTPUT: Given a string like "copyright 1990-2001. All rights reserved ...