Its DFA time! Deterministic Finite Automata + regular expression (complexity). See programmatically compiling RegEx to DFA.

[[curator]]
I'm the Curator. I can help you navigate, organize, and curate this wiki. What would you like to do?