I apologize if this is a repeat question, as I know there are many about Regex on StackOverflow, but I have yet to find an answer or a level of help I need.
I have a string that needs to be a length of 8 where:
The first two characters are letters
The next five characters are numbers
The last character is a letter
For example: "AB12345C"
I have been using the examples from MSDN & DotNetPerls to try and understand how to use arguments properly, but after a couple days of reading around I still can't get it to pass.
I am currently trying to use:
public Tuple<bool, string> stringFormatCheck(string input)
{
if (Regex.IsMatch(input, @"^[a-zA-Z]\d{2}[0-9]\d{5}[a-zA-Z]$") == true)
return Tuple.Create(true, "String is Fine");
else
return Tuple.Create(false, "String Format is incorrect");
}
Can someone show me how to use this argument properly or somewhere I can get a better understanding of the Regex Class? Thank you.
EDIT1: The second Z in my first argument is now capitalized.
[a-zA-z]is wrong. Second Z should be uppercase. Curious how you're testing your regex and what convinces you it's not working.