Regular Expression for Range (2-16)

后端 未结 5 2138
臣服心动
臣服心动 2021-02-05 06:45

I want to match a number between 2-16, spanning 1 digit to 2 digits.

Regular-Expressions.info has examples for 1 or 2 digit ranges, but not something that spans both:

5条回答
  •  眼角桃花
    2021-02-05 07:34

    (^[2-9]$|^1[0-6]$)

    By specifying start and stop for each set of numbers you are looking for your regex won't also return 36, 46, ... and so on. I tried the above solution and found that this works best for staying within the range of 2-16.

提交回复
热议问题