Reputation: 22556
I am struggling to make a RegExp to parse a string to determine if the number is in a certain range.
So what I am trying to achieve is:
From reading I will also have to make a special case for 1digit numbers?
I am using this to try and test:
Upvotes: 0
Views: 263
Reputation: 46841
Better way is to check conditionally in the code. If not possible then use regex at last resort
(?!325([0-2][0-9]|3[0-2])|65535)^[1-5][0-9]{0,4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-4]$
Read more about Negative Lookahead
Pattern explanation:
(?!325([0-2][0-9]|3[0-2])|65535)
is used to exclude certain number from the match.
^
and $
is used to match whole string/line from beginning to end.
Upvotes: 3