https://deniskyashif.com/2019/02/17/implementing-a-regular-expression-engine/ describes how to implement a regex engine from the parsing to the matching stage.