https://en.wikipedia.org/wiki/Brzozowski_derivative Should be relatively easy to implement for NFAs.