For a lot of modes, Emacs does this using regex.
Regex'ing languages like HTML or C++ can be quite mind breaking... I think.
For a lot of modes, Emacs does this using regex.