0

can anyone tell me how can I write RegEx for range between 20000 -42000 including comma, E.g. 35454.55 should be correct input... Thanks in advance! I have this code for range 1 - 25000, but I cannot figure out how to set upper range: ^([1-9]\d{0,3}|1\d{4}|2[0-4]\d{3}|25000)$

  • 1
    RegExp is a pattern-matching tool. It's not meant for comparing values arithmetically. While theoretically possible to do, it's better in terms of performance and maintainability to capture the value itself, cast it to the proper datatype, then perform comparisons in your language of choice (which appears to be JavaScript, based on your tags). – esqew Feb 22 '22 at 23:34
  • Ranges will give you a [hectic time](https://stackoverflow.com/questions/3148240/why-doesnt-01-12-range-work-as-expected). You can use a generator and alter it a bit to add periods and commas: https://3widgets.com/ – code Feb 22 '22 at 23:34
  • There's no comma in that number, it has a decimal point. – Barmar Feb 22 '22 at 23:36
  • This may be for an 's pattern attribute. OP, if you give more context, we can make better recommendations. – ChrisG Feb 22 '22 at 23:39

0 Answers0