Leandro Bardelli
Leandro Bardelli

Reputation: 11578

Regular Expressions with regularexpressionvalidator

I'm trying to create a

 <asp:regularexpressionvalidator>

with following conditions:

Eg:

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

Upvotes: 0

Views: 446

Answers (1)

Hans Kesting
Hans Kesting

Reputation: 39274

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

Upvotes: 3

Related Questions