The two regexes you give are equivalent to
\d{7} and
\d{1,7} respectively and they will both match a number of 7 digits. The second wil also match numbers of less than 7 digits. So your regex should not have failed. Perhaps this behaviour is caused by something else in your program. Can you show the program (if it is long, only the relevant parts).
CountZero
"If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law