I'm new to regex syntax and am looking for a way to match the following criteria:
- String has 1 alpha character and the rest are digits
- String starts with at least 1 digit but no more than 3
- Following character is a single alpha character (upper or lower case a-Z)
- Followed by 4 to 6 digits
Example valid data:
1A1111
1A11111
1A111111
11A1111
11A11111
11A111111
111A1111
111A11111
111A111111
Most examples I'm finding are matching 1 or more of a value so I'm struggling with how to match specific number of characters and what place they can be found in.
For example:
Matching 1 or more digits at the start of the string: @"^\d"
or Making sure the string has at least one Alpha character:
bool match = Regex.IsMatch(tokenString, @"(?=.*[^a-zA-Z])", RegexOptions.IgnoreCase);
But this doesn't tell it that there can be only 1 alpha character.