Alex
Alex

Reputation: 77329

What does the regular expression "\d{1,6}" check for?

What does the regular expression "\d{1,6}" (used in an ASP.NET MVC route as parameter constraint) check for/allow?

Upvotes: 0

Views: 20166

Answers (4)

xrath
xrath

Reputation: 854

\d means a single decimal character. 0~9.

{minimum-length, maximum-length} means a precede expression (\d in this case) will be followed repeatedly.

As a result, your expression \d{1,6} would match any of them.

0 12 874 4757 48727 557473

Upvotes: 1

Bill the Lizard
Bill the Lizard

Reputation: 405765

That will match 1-6 consecutive occurrences of any of the digits 0-9 (not necessarily the same digit).

Upvotes: 19

RageZ
RageZ

Reputation: 27313

\d is the class for digits the {1,6} means one to six element(s) of that class

if you want some reference you can consult this website probably not the best but kind of nice summary.

Upvotes: 4

Devin Ceartas
Devin Ceartas

Reputation: 4829

a number with 1-6 digits

Upvotes: 4

Related Questions