my %map = ( '\n' => "\n", '\t' => "\t" ); $_ = "whatever"; s/(\\[ntf\\])/$map{$1}||'?'/g