It sounds like you misunderstood how the definition of character classes in regular expressions works.
To match any of lines 01 , 02 , 03 , 04 , 05 , 06 , 07 , 08 , 09 , 10 , 11 or 12 , it works something like this:
0[1-9]|1[0-2]
Recommendations
explanation
The character class itself tries to match one and exactly one character from the input string. [01-12] actually defines [012] , a character class that matches one character from input against any of the 3 characters 0 , 1 or 2 .
- definition of the range goes from 1 to 1 , which includes only 1 . On the other hand, something like [1-9] includes 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 .
Beginners often make mistakes by defining things like [this|that] . This does not work". This character definition defines [this|a] , ie it matches one character from the input to any of the 6 characters in t , h , i , s , | or. a More than likely (this|that) what is intended.
Recommendations
How ranges are defined
So now it’s obvious that the circuit, for example, between [24-48] hours , doesn’t “work”. The character class in this case is equivalent to [248] .
That is - in the definition of a character class it does not determine the numerical range in the template. Regex engines do not really "understand" the numbers in the template, except for the syntax with finite repetition (for example, a{3,5} corresponds to 3 to 5 a ).
Instead, range definition uses ASCII / Unicode character encoding to define ranges. The character 0 is encoded in ASCII as the decimal number 48; 9 is 57. Thus, the definition of the character [0-9] includes all characters whose values are between decimal 48 and 57 in encoding. It is very reasonable that, by design, these are the symbols 0 , 1 , ..., 9 .
see also
Another example: A to Z
Let's look at another definition of the common character class [a-zA-Z]
In ASCII:
A = 65, Z = 90a = 97, z = 122
It means that:
[a-zA-Z] and [A-Za-z] equivalent- In most flavors,
[aZ] may be an invalid character range- therefore
a (97) is "greater than" than Z (90)
[Az] is legal, but also includes the following six characters:[ (91), \ (92), ] (93), ^ (94), _ (95), ' (96)
Related issues
- is the regular expression [aZ] valid and if so is it the same as [a-zA-Z]