A simple regex engine in C++