I am trying to develop a regular expression to validate a string that comes to me like: “TE33” or “FR56” or any sequence respecting 2 letters and 2 numbers.
The first 2 characters must be alphabetic and 2 last caracters must be numbers.
I tried many combinations and I didn’t have success. Last one I tried:
if(Regex.IsMatch(myString, "^[A-Za-z]{2}[0-9]{2}")){
}
You’re missing an ending anchor.
Here’s a demo.
EDIT: If you can have anything between an initial 2 letters and a final 2 numbers:
Here’s a demo.