$string = "jgfh4u4jfr23jkjvj"; $string =~ s/([3-6])/\n$1/g; print $string;