---
title: "When Are Regexes Appropriate?"
canonical: "/2017/05/24/when-are-regexes-appropriate/"
date: "2017-05-24"
author: "Alok Singh"
tags: []
---


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.
