[regex] 6 digits regular expression

I need a regular expression that requires at least ONE digits and SIX maximum.

I've worked out this, but neither of them seems to work.

^[0-9][0-9]\?[0-9]\?[0-9]\?[0-9]\?[0-9]\?$

^[0-999999]$

Any other suggestion?

This question is related to regex vb.net

The answer is


  ^\d{1,6}$

....................


^[0-9]{1,6}$ should do it. I don't know VB.NET good enough to know if it's the same there.

For examples, have a look at the Wikipedia.


You could try

^[0-9]{1,6}$

it should work.


\b\d{1,6}\b

Explanation

\b    # word boundary - start
\d    # any digits between 0 to 9 (inclusive)
{1,6} # length - min 1 digit or max 6 digits
\b    # word boundary - end