Is there any way to check for a number in a string within an exact range using purely regex?
What I mean is that I want to check if a string contains a number that ranges, for example, from 1 to 31 in VALUE, not length.
The numbers of the range from 1 to 31 can be split into two groups: one digit numbers (1–9) and two digit numbers (10–31). And the latter can further be split into whole decades (10–29) and partial decades (30–31). These can be expressed as follows:
And to match only whole numbers and not just parts of them, you could use look-around assertions:
(?<!…) means not preceded by
(?!…) not followed by