To be honest, this depends on the implementation. A good general introduction to the kind of algorithms used by regular expression parsers can be found in
Mastering Regular Expressions[
^] by Jeffrey Friedl. If you are serious about regular expressions then you should have this book.
As to how a regex engine handles things in practice, look at the code for
Boost.Regex[
^]. The code is freely available.