use utf8; my $str = "725-275 is an entry - and will be at 423-569 -but- not at 012-457."; $str =~ s/(\d{3})-(\d{3})/\1\_\2/g; print "$str\n"