I need a regex string for validating an account code. The code is four characters that has to start with an alpha followed by an alphanumeric then followed by numerals only (i.e. AC23
, D345
, CT75
)
I currently have the following statement that will throw error
if (!Regex.Match(iLineItem.Code, @"^[A-Za-z0-9][A-Za-z0-9]*$").Success)
yield return new RuleViolation("Code has invalid format.", "Code");
How can I change the string to not allow A99A
as a code?
Thanks in advance!