How do I represent regular expression number ranges (e.g., 1 to 12)?

I am currently using ([1-9]|1[0-2])1 to 12 to represent inputs. (Leading zeros are not allowed.)

However, it seems pretty hacked, and on some days it looks frankly dirty .

☞ Is there a built-in way right ?

☞ What other ways to represent ranges of numbers?

+7
source share
5 answers

, [2-9]|1[0-2]?, , . XML-, "", .

+6

, :

[1-9]|1[0-2]

10.

+8

:

[1-9]|1[012]
+6

, 1 12.

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

HTML, , "1111" "1212", .

+2

:

^[1-9]|10|11|12$

0-9 10 11 12. , .

0

All Articles