Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
I tried this, but in this case, 11 and 12 are allowed too:
^[0-9]{10,13}$
I need just 10 or 13.
You can do also
^\d{10}(\d{3})?$
10 digits + optional 3 digits
Add a comment
You could use alternation (matches the regex before or after):
^[0-9]{10}|[0-9]{13}$
This would match 10 or 13 digits.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.