cli regex notes

which flavour of "regex" are we talking about?

SEAN K.H. LIAO

cli regex notes

which flavour of "regex" are we talking about?

cli tools

The unix way: lots of tiny tools. Unfortunately this also means the same thing is implemented many times, with differing results. Like regex

regex

Thankfully these mostly fall into 2 groups:

both sed and grep take -E to switch to extended mode

            sed     vim        grep    awk        ripgrep    sd
grouping    \(\|\)  \(\|\)     \(\|\)  (|)        (|)        (|)
list        []      []         []      []         []         []
classes     [[:c:]] [[:c:]] \w [[:c:]] [[:c:]] \w [[:c:]] \w [[:c:]] \w
0+          *       *          *       *          *          *
0+ ungreedy                                       *?         *?
1+          \+      \+         \+      +          +          +
0,1         \?      \?         \?      ?          ?          ?
count       \{x,y\} \{x,y\}    \{x,y\} {x,y}      {x,y}      {x,y}

other

Here's a gist on a some regex engines, and wikipedia.