I'm trying to create regex and test in javascript.
RULE: The text should only be 8 characters. Only contain Upper case and numbers 1-5 No lower case or special characters or 6-7 numbers.
example:
12345678 -- false a2345678 -- false aabbccdd -- false AABB33DD -- true // contains BOTH uppercase and numbers between 1-5 and nothing else AABB88DD -- false AABBCCDD -- false AABB3.DD -- false CODE:
var pattern = new RegExp("^(?=.*[1-5])(?=.*[A-Z]).+$"); pattern.test(code) I'm not able to crate the right regex. Can anyone please help?
/^[A-Z1-5]{8}$/AAAAAAAA