$t='12345Y'x10; $s=''; $t=~m!(?:(\d(?{$s.=$1}))\D*){13}!; print "$s\n";