# Minimizing the length of regular expressions, in practice

DevFeed: [Minimizing the length of regular expressions, in practice](<https://devfeed.tech/articles/minimizing-the-length-of-regular-expressions-in-practice-27405.md>)

Original publisher: [Read original article](<http://engineering.khanacademy.org/posts/shortest-regex.htm>)

Author: Khan Academy

Published: 2016-05-23T22:00:00Z

Content type: tutorial

Language: en

Sources: [Khan Academy](<https://devfeed.tech/sources/khan-academy.md>)

Topics: [Algorithms, Complexity](<https://devfeed.tech/topics/algorithms-complexity.md>), [Regular expression](<https://devfeed.tech/topics/regular-expression.md>), [Programming](<https://devfeed.tech/topics/programming.md>), [cloud-infrastructure](<https://devfeed.tech/topics/cloud-infrastructure.md>)

Tags: [algorithms](<https://devfeed.tech/tags/algorithms.md>), [cdn](<https://devfeed.tech/tags/cdn.md>), [configuration](<https://devfeed.tech/tags/configuration.md>), [engineering](<https://devfeed.tech/tags/engineering.md>), [google](<https://devfeed.tech/tags/google.md>), [hosting](<https://devfeed.tech/tags/hosting.md>), [infrastructure](<https://devfeed.tech/tags/infrastructure.md>), [news](<https://devfeed.tech/tags/news.md>), [re](<https://devfeed.tech/tags/re.md>), [repository](<https://devfeed.tech/tags/repository.md>), [software-engineering](<https://devfeed.tech/tags/software-engineering.md>)

## AI overview

Craig Silverstein explains how Khan Academy needed a compact regular expression to distinguish static URLs from dynamic URLs for CDN routing. The article describes why simple patterns were unsuitable, reports that a naive generated expression reached 402,025 characters, and introduces a second approach that reduced the length to 2,400 characters.

## Source excerpt

By Craig Silverstein The problem Software engineering interviews tend to be full of "algorithms" questions, because they're easy ... Read more