I’m trying to make a regex that only allows the user to input numbers with a value of 2 or more (0 and 1 are not allowed)…
I have been trying to pull this off for quite a while with no success yet…
I have tried this one for example:
[2-9]|([1-9][0-9]+)
Either you take a single number from 2 to 9, or you input any number different from 0 AND at least another number…
that way there’s no way the user can input either 0 or 1…
I don’t know if there’s a syntax error there or what should I do?
Thanks in advance.
I would suggest that you Int32.TryParse first and then test whether the value you get is in the range that you want. Here’s a rough idea:
Regex isn’t meant for what you are trying to accomplish.