Regex Help Requied

Hello

I know Javascript, but when it comes to Regex, i m not good at it.

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.

Thanks
ZH

Great !

Thank you all .

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

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

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}$/

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.