I'm interested in a concise way to specify different allowable lengths for a string of numbers. I want to allow strings of length 2, 4, 6, 8, and 10, but nothing in between. The following works just fine, but it is a bit long-winded:
var regex = /^([0-9]){2}|([0-9]){4}|([0-9]){6}|([0-9]){8}|([0-9]){10}$/;
Is there a shorter, less brute force way I can do this?
Thanks!
[0-9]by\dstring.length()and check the value of that