in reply to regex help

If you simply want a regular expression that matches six digits and other optional text, the following should work:

$imgNumber =~ /^(\d{6})(.*)\.jpg$/

This saves the six digits in $1 and the optional text in $2 (excluding the extension).