a regular expression generator for number ranges

前端 未结 9 2173
长情又很酷
长情又很酷 2021-02-04 05:56

I checked on the stackExchange description, and algorithm questions are one of the allowed topics. So here goes.

Given an input of a range, where begin and ending number

9条回答
  •  广开言路
    2021-02-04 06:09

    If you find regex pattern range between 5 and 300 which also support float; there is the best answer created by me ...

    ^0*(([5-9]([.][0-9]{1,2})?)|[1-9][0-9]{1}?([.][0-9]{1,2})?|[12][0-9][0-9]([.][0-9]{1,2})?|300([.]0{1,2})?)$
    

    for 1 to 300 range

    ^0*([1-9][0-9]?([.][0-9]{1,2})?|[12][0-9][0-9]([.][0-9]{1,2})?|300([.]0{1,2})?)$
    

提交回复
热议问题