2 ms·
Shameless plug: I've written books [1] which focuses entirely on the specific flavor supported by the tool or the programming language. I use plenty of examples
by asicsp 7y ago
Shameless plug: I've written books [1] which focuses entirely on the specific flavor supported by the tool or the programming language. I use plenty of examples to present the features one by one. These can be used for learning purposes as well as handy reference guide.
I think of regular expressions as a mini-programming language, and use loose fitting analogies
Anchors --> adding if conditions
Alternation --> Conditional OR
a(b|c)d = abd|acd --> a(b+c)d = abd+acd
Quantifiers --> string repetition and range operators
Dot metacharacter + quantifiers + alternation --> Conditional AND
Capture group and backreference --> variable
Subexpression call --> function
Character class --> sets
Lookarounds --> custom conditionals
Flags --> like command line options
So far, I've written books for Ruby and Python regular expressions, and BRE/ERE/PCRE/Rust for "GNU grep and ripgrep". Currently writing a book for GNU sed.
[1] https://learnbyexample.github.io/books/ https://learnbyexample.github.io/books/