Regular Expression allow only numbers, commas and dashes

Viewed 12470

I'm trying to come up with a Data Annotation regular expression to match the following formats.

34

38-30

100,25-30

4-5,5,1-5

Basically the expression should only allow numbers, -(dash) and ,(comma) in any order

I tried following but couldn't get it working.

[RegularExpression(@"(0-9 .&'-,]+)", ErrorMessage ="Lot numbers are invalid.")]
2 Answers
Related