use warnings; use strict; while () { s/(\d+)(th|st|nd|rd)/$1/; print; } __DATA__ December 14th 2012 December 21st 2012 December 22nd 2012