0

I tried this, but in this case, 11 and 12 are allowed too:

^[0-9]{10,13}$ 

I need just 10 or 13.

1
  • 1
    I've fixed a couple of typos in your question. Please review my edit to make sure I didn't change your intended meaning. Commented Mar 26, 2014 at 20:32

2 Answers 2

6

You can do also

^\d{10}(\d{3})?$ 

10 digits + optional 3 digits

Sign up to request clarification or add additional context in comments.

Comments

4

You could use alternation (matches the regex before or after):

^[0-9]{10}|[0-9]{13}$ 

This would match 10 or 13 digits.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.