Isn&#x27;t arbitrarily-long nesting or matching any sort of palindrome, where you count up and down, the classic case of something you should never do with a regex, because they&#x27;re <i>finite</i> automata?<p>People don&#x27;t build parsers because of masochism, but because regular expressions are provably insufficient to capture things like nesting. You need to go at least one level up on the Chomsky hierarchy[1] to pushdown automata for that.<p>More importantly, shouldn&#x27;t SOMEBODY working on a text editor know and recognise this sort of thing? I&#x27;m all for the hacker mentality of shipping, reducing developer time instead of machine time, using what you know, but this is the sort of hacky fix that just pushes the problem further down the line.<p>Great write-up though, very enjoyable read!