Real-world regexs are extensions of regular expressions in formal languages.
Do lookahead and lookbehind come from some type of formal languages? (I suspected lookahead in LR(k) grammars, simply because of the same name, but I have difficulty to either confirm or unconfirm it. Not sure about lookbehind.)
Btw: I have been interested in which extensions in regexes come from which types of formal languages. Do you know somethings for me to read?
Thanks.
No, they are pragmatic hacks based on features found to be useful by programmers and implementable by library maintainers.
Most aspects of programming libraries follow this paradigm. The theory is important, and it probably could be used better. But it's s very rare for someone to decide to omit a useful feature just because it is not part of a theoretical framework.
Just to be clear, lookahead assertions in regex libraries have nothing to do with parser lookaheads, except that both represent answers to the question "What comes next?" (but not in the same problem domain).