var patt = new RegExp("^(\d{3}|\d{5})&");
var re=new RegExp('^(\\d{3}|\\d{5})$'); alert(re.test(12)); alert(re.test(123)); alert(re.test(1234)); alert(re.test(12345)); alert(re.test(123456));