Reputation: 299
I have an input field where it will accept only numbers between 2-200 and it should be even numbers.I want the regular expression for all the even numbers between 2-200 please help.
Upvotes: 1
Views: 218
Reputation: 785721
If you really must do via regex then this will work:
^(?!.*?[13579]$)([2-9]|[1-9][0-9]|1[0-9]{2}|200)$
Upvotes: 2
Reputation: 11233
Regex is not something design to find the number in a range, you should preferably use:
if( (2 <= number <= 200) && (number %2 ==0))
{
// doyour stuff
}
Upvotes: 3