Is it possible to create a regex that matches all strings with five a’s and five b’s?
Like aaaaabbbbb or ababababab or aabbaabbab.
I imagine it would require polynomial time for a deterministic engine.
Are there other matching languages which would enable such matching?
Update:
I wanted to use the kind of expression for searching, so I changed the one purposed to (?=b*ab*){5}(?=a*ba*){5}([ab]{10}) and it works nicely! 🙂
I’m still uncertain with respects to the performance of an expression like that. But I guess I can just look up lookahead expressions.
I’m still curious to which other kinds of patterns, that are simple to explain but hard to regex, are out there?
You can use lookahead assertions: