An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
Try this simple expression too:
^[0-9]{1,4}[a-zA-Z]?$
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I am convinced that this requirement is so simple it's embarrassing to ask but for some reason it is escaping me, perhaps I don't know enough about Regular Expressions. :)
All I need to do is validate a string which needs to match 1-4 numbers followed optionally by a single letter (upper or lower case a-z). so 9, 8a, 225z are all valid but, a, 2ab, 12345a, are invalid.
All help very welcome!
ps I have no idea what I'm wanted to enter under "Tags" so I just picked one at random!
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
Try this simple expression too:
^[0-9]{1,4}[a-zA-Z]?$
Please try if this can meet your needs:
Regex regex = new Regex(@"(?<=^[0-9]{1,3}(?:a|A|z|Z|$)\b)");
string test = "123a";
bool re = regex.IsMatch(test);
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.