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

How to Disable Disqus Ads on your Blog

Derivation of Reservoir Sampling

Fun with Python Iterators: Linked Lists Made Easy

Notes for November 11, 2018

Underrated Vim Option: undofile and undodir

Hot Take on Solo Travel: Starve

Alan Perlis

Book Notes: The Map of My Life by Goro Shimura

Prague

Way to remember the definition of local finiteness