my $test = "21234"; #if($test=~/(\d+){4}/) #if($test=~/\d\d\d\d{4}/) #if($test=~/\d\d\d\d/) #if($test=~/\d\d\d\d{4}/) #if($test=~/^(\d+){4}?/) if($test=~/\d+{4}/) { print "0$test\n"; } else { print "$test\n"; }