Reputation: 65
I beseech thee, oh gods of the mighty RegEx... hear my plee!!!
I need a Regex for the following rules
-Number has to be 6 characters long
-Number has to start with 5
Number cannot start with "50****" or "589***"(It can start with 51, 52, 587, 583, etc...)
What I'm working off of right now is
^5(?!(0\b|89\b))\d+\b.
Please HELP!!!
Upvotes: 2
Views: 33
Reputation: 67968
^5(?!(?:0|89))\d{5}$
This should do it for you.See demo.
https://regex101.com/r/hE4jH0/1
You dont need \b
after 0
or 89
as you dont expect a word boundary
there.
Upvotes: 2