Regular expression for validating numeric values

Posted by Michael Kniskern on Stack Overflow See other posts from Stack Overflow or by Michael Kniskern
Published on 2010-05-25T21:05:02Z Indexed on 2010/05/25 21:11 UTC
Read the original article Hit count: 161

Filed under:

I current have the following regular expression to accept any numeric value that is seven digits

^\d{7}

How do I improve it so it will accept numeric value that is seven or ten digits?

Pass: 0123456, 1234567, 0123456789, 123467890
Fail: 123456, 12345678, 123456789

© Stack Overflow or respective owner

Related posts about regex