my %lookup = ( 2019 => ', # replace &rsqu with an apostrophe 2010 => -, # hyphen etc. ); $text = s/(.)/$lookup{$1}?$lookup{$1}:$1/eg;