hope everything’s great with everyone.
can someone please help me to create regexp to validate the following value format
valid values :
1-24; (1000,125),(1000,125),(1000,125)
1-10; (1000,125)
1-15; (1000,125),(1000,125)
** where the 1-24; should be the range of values to apply; max value should be 24
invalid values :
1-15; (1000,125),
1-50; (1000,125)
1; (1000,125)
thanks guys!
OK, in light of your comment I think I get what you’re asking for. You’re saying that to be valid, the entered value must start with a number between 1 and 24, then a dash, then another number between 1 and 24, then a semicolon and a space, then 1 or more pairs of numbers in brackets. The bracketed pairs should be separated by commas, but no trailing comma.
Based on that understanding I would suggest a regex something like this:
Sorry, regarding the “x-y” range at the beginning I’m not aware of a regex method to validate that the second number is greater than or equal to the first. And the numbers in the brackets apparently allow decimal places, but you’ve given only examples, not rules about how many digits, maximum or minimum values or whatever so I’ve just assumed at least one digit followed optionally by a decimal place and at least one more digit.
I have not tested the above. If anything in the expression doesn’t make sense to you feel free to look at one of the seven zillion regex guides on the web, e.g., http://www.cheatography.com/davechild/cheat-sheets/regular-expressions/