I have a field in a form that takes the following values: -1, 2-10, 99
I have a business rule regarding answers 2-10.
I am trying to write a regex that will match 2-10, but not 99, and I'm having problems.
Original expression:
^2|3|4|5|6|7|8|9|10$
Does not work because 99 matches (technically, twice). In addition, linear boundaries are something that I never liked. I observe different expressions in the expression than in other places (e.g. .net). In this particular case, the regular expression is executed in javascript . In any case, expresso seems to ignore them (and if I put the values ββin brackets:
^[2|3|4|5|6|7|8|9|10]$ ^[2-9]$
either "everything is spelled out" or as a range, expresso never returns any matches if I specify a line / line to close a line / line of a line (and yes, I tried to match 10 separately in the second case).
I know, I know. If you use regex to solve a problem, you have two problems (and presumably they will start inviting friends, style 1 and style 2). I cannot have to use it here; I can go to the description of the case. But it seems to me that I can use a regex here, and that seems like a reasonable deal. I'm still pretty green when it comes to regex;
javascript regex
peacedog
source share