Trying to build a regular expression to check pattern

后端 未结 7 743
我在风中等你
我在风中等你 2021-01-20 17:32

a) Start and end with a number
b) Hyphen should start and end with a number
c) Comma should start and end with a number
d) Range of number should be from 1-31

7条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-20 18:10

    An optimal Regex for this topic could be:

    ^(?'int'[1-2]?[1-9]|3[01])((,\g'int')|(-\g'int'(?=$|,)))*$
    

    demo

提交回复
热议问题