in reply to regex help

I think what you want is something like the following:
my $str = '012346.jpg 012346-all.jpg 012346-EXP.jpg'; while ($str =~ /(\d+)(.*?\.jpg)/gi) { print "$1$2\n"; }
Where $1 is the number, $2 the rest.