I’m trying to find a halfway decent regex for a string exactly 8 characters long. Those 8 characters should be comprised of a’s followed by b’s.
Another way of putting this would be a{n}b{8-n} where n=0…8
Example Matching Strings:
aaaaaaaa
abbbbbbb
aaaabbbb
bbbbbbbb
Example Non-Matching Strings:
bbbbaaaa
aaaabaaa
There are many ways to do it. Here’s another alternative:
Of course you can switch around what’s in the lookahead: