couldn't find anyone actually answering ur question so basically regexp on the implementation level is the most basic shit you can do in programming, loop each character and check it, then check it again when you loop to the second character and so on
look at the source code for perl's regexp sometime, it tells you a lot about how stuff like this is done, there are some while loops in there spanning over thousands of lines, all to process each character and the overall syntax in your regexp
if you don't understand that very basic explanation then gtfo