You could try something like this:
[a-zA-Z]{2}[0-9]{6}
Here is a break down of the expression:
[a-zA-Z] # Match a single character present in the list below
# A character in the range between “a” and “z”
# A character in the range between “A” and “Z”
{2} # Exactly 2 times
[0-9] # Match a single character in the range between “0” and “9”
{6} # Exactly 6 times
This will match anywhere in a subject. If you need boundaries around the subject then you could do either of the following:
^[a-zA-Z]{2}[0-9]{6}$
Which ensures that the whole subject matches. I.e there is nothing before or after the subject.
or
\b[a-zA-Z]{2}[0-9]{6}\b
which ensures there is a word boundary on each side of the subject.
As pointed out by @Phrogz, you could make the expression more terse by replacing the [0-9]
for a \d
as in some of the other answers.
[a-zA-Z]{2}\d{6}