I need a javascript code based on regex that can check if the data in a text box is like this format :

9AA
Means, first character must be a DIGIT and the last 2 must be ALPHABETS.

Next, the other text box must have data like below format.

A9
A99
AA9
AA99
A9A
AA9A

Please support.

ThanksZH

zeeshanhashmi
—
2010-10-25T07:12:29Z —
#2

Great !

Thank you all .

Logic_Ali
—
2010-10-24T19:20:32Z —
#3

/^\\d[^A-Z0-9]*[A-Z]{2}$/
/^[A-Z]{1,2}\\d{1,2}[A-Z]?$/

zeeshanhashmi
—
2010-10-25T03:08:58Z —
#4

Thanks Ali !

In your pattern :

/^\d[^A-Z0-9]*[A-Z]{2}$/

the first A-Z0-9 means it can have alphabets and numbers, so if I only want numbers there, can i make it :

/^\d[^0-9]*[A-Z]{2}$/

Chroniclemaster1
—
2010-10-25T06:26:17Z —
#5

Exactly, that would only accept numbers, not letters for the first character. Everytime you use a hyphen, regex includes everything in between the respective Unicode code points; since capital letters, lower-case letters, and numbers each have contiguous spots, you can call each group together.

U+0030{0}-U+0039{9}U+0041{A}-U+005A{Z}U+0061{a}-U+007A{z}

If you look over the Unicode charts you can include any set of contiguous characters in this way.