I am using ExtJS. One of the textfield made with ExtJS component should allow comma separated number/opeator strings (3 similar examples) like
1, 2-3, 4..5, <6, <=7, >8, >=9
>2, 3..5, >=9,>10
<=9, 1, <=8, 4..5, 8-9
Here I am using equals, range (-), sequence (..) & greater than/equal to operators for numbers less than or equal to 100. These numbers are separated by a comma.
What can be a regular expression for this type of string?
For my previously asked question.. I got a solution from "dlamblin":
^(?:d+(?:(?:..|-)d+)?|[<>]=?d+)(?:,s*d+(?:(?:..|-)d+)?|[<>]=?d+)*$
This works perfect for all patterns except:
Only if relationship operators (
<
,<=
,>
,>=
) are present as first element of the string. E.g.<=3, 4-5, 6, 7..8
works perfect, but<=3, 4-5, 6, 7..8, >=5
relationship operator not at 1st element of string.Also string
<3<4, 5, 9-4
does not give any error i.e. it is satisfying condition though comma is needed between<3
and<4
.Numbers in the string should be less than or equal to 100. i.e.
<100
,0-100
,99..100
It should not allow leading zeros (like
003
,099
)