Reputation: 131
For my regex, I want letters from a-z 1-4 times followed by any digit 4-7 times. The combination of these two should have 8 characters total. something like this
([a-z]{1,4}[0-9]{4,7}){8}
I know this is wrong. Can anyone tell me the right regex expression to make this work
Upvotes: 2
Views: 55
Reputation: 70732
You can use a lookahead based regular expression to assert the string length is exactly eight characters.
^(?=.{8}$)[a-z]{1,4}\d{4,7}$
Upvotes: 2