I’m trying to create a
<asp:regularexpressionvalidator>
with following conditions:
- String must be have 8 chars.
- String must contains 8 alphanumeric chars in any order, letters must be capitals.
Eg:
- YES: 12345678
- YES: A2345A78
- YES: ABCDEFGH
- NO: 1234a567
- NO: ABCdEfgh
- NO: abcdefgh
- NO: a.bc-feg
by the way, anyone knows a good regex online creator? Thanks
RESOLVED: For the first answer view the accepted answer, for the second view the first comment of this post by Jeff Turner
For the validator, this will work:
[A-Z0-9]{8}. For a plain Regex match, you would need to specify that that should match the whole string, like^[A-Z0-9]{8}$, but the regex validator already has an extra rule that the whole string must be matched instead of just a part.Explanation:
[A-Z0-9]will match any capital letter (A .. Z) and any digit (0 .. 9){8}repeat the previous exactly 8 times