I’m using a regular expression to validate a certain format in a string. This string will become a rule for a game.
Example: “DX 3” is OK according to the rule, but “DX 14” could be OK too… I know how to look at the string and find one or more “numbers”, so the problem is that the regex will match 34 too, and this number is out of “range” for the rule…
Am I missing something about the regex to do this? Or is this not possible at all?
Unfortunately there’s no easy way to define ranges in regex. If you are to use the range 1-23 you’ll end up with a regex like this:
Explanation: