On Fri, Mar 3, 2023 at 5:59 AM Ralph Corderoy <ralph(a)inputplus.co.uk> wrote:
[snip]
If you want to understand:
- the maths of regular expressions,
- the syntax of regexps which these days expresses more than REs, and
- the regexp engines in programs, the differences in how they work and
what they match, and
- how to efficiently steer an engine's internals
then I recommend Jeffrey Friedl's Mastering Regular Expressions.
http://regex.info/book.html
I'm afraid I must sound a note of caution about Friedl's book. Russ
Cox alludes to some of the problems in the "History and References"
section of his page (
https://swtch.com/~rsc/regexp/regexp1.html) that
was linked earlier, and he links to this post:
http://regex.info/blog/2006-09-15/248
The impression is that Friedl shows wonderfully how to _use_ regular
expressions, but does not understand the theory behind their
implementation.
It is certainly true that today what many people refer to as "regular
expressions" are not in fact regular (and require a pushdown automata
to implement, putting them somewhere between REs and the context-free
languages in terms of expressiveness).
Personally, I'd stick with Russ's stuff, especially as `egrep` is the
target here.
- Dan C.