I need to match a pattern with strictly 10-symbols length OR 12 (not 11). So this won't work
[0-9]{10,12}
Can I write something more simple than
([0-9]{10}|[0-9]{12})
?
I need to match a pattern with strictly 10-symbols length OR 12 (not 11). So this won't work
[0-9]{10,12}
Can I write something more simple than
([0-9]{10}|[0-9]{12})
?
You can use ? to set a char or group as optional :
\d{10}(\d\d)?
Don't forget to match start and end if that's the whole regex :
^\d{10}(\d\d)?$