Reputation: 9279
I have an MVC3 C#.NET web app. I have two properties that are doubles and can have the (value >= 0) and (value <=2). I would like to use a regular expression to limit the values for thes two fields. Ideas?
Upvotes: 0
Views: 4425
Reputation: 265547
I really don't think regex is a good idea here, but if you want to know …
Let's break it down to what you need to match: 0(.XXXX), 1(.XXX), and 2(.0)
var regex = new Regex(@"0*([01](\.[0-9]*)?|2(\.0*)?)");
Upvotes: 1