I wish to write a regular expression to check wind direction condition(s). I want input from the user something like this:
BETWEEN (45 AND 90) OR (270 AND 320)
BETWEEN, AND and OR are of course keyword there can be multiple conditions within brackets () separated by OR
For example:
BETWEEN (45 AND 90)
BETWEEN (45 AND 90) OR (270 AND 320)
BETWEEN (15 AND 40) OR (170 AND 200) OR (270 AND 320)
BETWEEN (45 AND 90) OR (270 AND 320) OR (220 AND 240) OR (270 AND 320)
Numeric values should be between 0 and 360. I want to give the user option to input multiple conditions.
Try this:
This is pretty long, but it makes sure that you only have
ORbetween multiple directions and not at the end or the beginning. The length number-strings also make sure you only have numbers from 0 (or 000) to 360.However, you should consider, whether splitting your string at
ORandANDmight be a simpler solution.