Regular Expression to match 0, 10, 20, 30, 40 or 50

4 views
Skip to first unread message

Ben

unread,
Oct 13, 2009, 5:12:47 PM10/13/09
to Regex
Is it possible for a regular expression to validate whether a number
is equal to 0, 10, 20, 30, 40 or 50? If so, do you know the syntax?

Accmailer

unread,
Oct 14, 2009, 2:55:52 AM10/14/09
to Regex
simple!
[1-5]?0
that means one optional digit ranging from 1 to 5 followed by an
obligatory zero

while this would be the same (1|2|3|4|5)?0

as a precaution you may add
1)optional spaces...
\s*[1-5]?0\s*

and
2) start of input and end of input anchors
^\s*[1-5]?0\s*$

Ben

unread,
Oct 14, 2009, 9:23:52 AM10/14/09
to Regex
Yep, very simple! Thanks very much!
> > is equal to 0, 10, 20, 30, 40 or 50? If so, do you know the syntax?- Hide quoted text -
>
> - Show quoted text -
Reply all
Reply to author
Forward
0 new messages