John Roberts
John Roberts

Reputation: 5984

Regex for Number Range 200 - 800 in Increments of 10

I am trying to write a regex to validate GMAT scores, which go from 200 - 800 in increments of 10. So far, I have been able to come up with validating all numbers from 200 - 800:

^([2-7][0-9]{2}|800)$

Can anyone help?

Upvotes: 2

Views: 407

Answers (2)

Boris Šuška
Boris Šuška

Reputation: 1794

Isn't it?

^([2-7][0-9]0|800)$

Increments by 10 means it has to end by zero.

Upvotes: 1

Explosion Pills
Explosion Pills

Reputation: 191819

It seems like you just want to end with a literal 0

^([2-7][0-9]0|800)$

Upvotes: 4

Related Questions