I want to validate an input of format “AB1234” where first two characters must be Alpha (A-Z) and remaining must be numbers.
My current regex is validating the input “AB123A” which is incorrect. What is missing my current regex?
^[a-zA-Z]{2}\d{1,6}
You are missing
$which specifies the end of the string^[a-zA-Z]{2}\d{1,6}without$matchesAB123Asince you are not specifying anyendto that string..It matches
AB123withinAB123A