问题描述:

I need regular expression validation for first 5 digits are numbers then hyphen and then one digit is alphabet and other one is numeric.

ex : 23456-p5 or 12345-a3 something like that.

I have tried something like this to start with

/^\d{5}-\d{2}$/

and in model i have given like this as we don't have to give ^ or $ in data annotations

[RegularExpression(@"d{5}-\d{2}")]

But i couldnt get it to work even this.

网友答案:

Try this:

[RegularExpression(@"^\d{5}-[a-zA-Z]\d$")]
网友答案:

An expression like this should work:

^\d{5}\-[A-Za-z]\d$
相关阅读:
Top