Reputation: 8950
I am trying to build a regex for following rules
I am able to achieve regex for points 1
, 2
and 3.1
like this
^[2-9]{1}[0-9]{7,}$
But I am not able to find solution for point 3.2
This is one of the options I started with, this regex matches the string that must start with 20, 21, 22, 23, 24, 25, 26, or 27.
^([2][0-7])[2-9]{1}[0-9]{7,}$
I just have to find the negation of this first condition.
Please help!
Upvotes: 2
Views: 133
Reputation: 147146
Rather than trying to negate the 20-27
condition, just match numbers that start with 28
or 29
instead:
^(?:2[89]|[3-9]\d)\d{6,}$
Upvotes: 5