Sreekumar P
Sreekumar P

Reputation: 6050

Regular Expression - Accept 15 to 17 Digits

I want a regular expression that accepts numeric only between 15 to 17 digits.

Upvotes: 4

Views: 4542

Answers (1)

Kobi
Kobi

Reputation: 138147

^\d{15,17}$ - For any digit (use [0-9] instead of \d to avoid Unicode characters, if applicable).
^[1-9]\d{14,16}$ - If you don't want the number to start with all zeros.

Of course, it might be easier to parse the number and check it, it fits nicely in a long value.

Upvotes: 7

Related Questions