When Are Regexes Appropriate?


Regular expressions are useful enough that they're built in to the syntax of the shell. But they're not always the right tool. Here's my off-the-cuff heuristics for when to use them.

If there is any sort of arbitrary nesting (like nested quotes and parens) and you need perfect accuracy on all sorts of inputs, don't use regex.

If the input isn't pathological, if accuracy isn't required, or if you need speed, use regex.

Related Posts

Some ChatGPT Sessions

2016 ML thoughts

My biggest takeaway from Redwood Research REMIX

finite, actual infinity, potential infinity

Actions and Flows

PSA: reward is part of the habit loop too

a kernel of lie theory

The hyperfinite timeline

Slick hyperfinite Ramsey theory proof

Gaoxing Guy