TLDR Tech / Dev
Finding all regex matches has always been O(n²). even in the engines built to prevent it
Most regex engines, despite claiming linear time for single matches, exhibit a quadratic (O(n²)) performance issue when finding all matches. RE# is a new regex engine that addresses this by using a two-pass algorithm with a reverse and a forward DFA to efficiently identify all leftmost-longest matches in guaranteed linear time. It includes a "hardened mode" for linear performance against adversarial inputs, and its default mode also offers high speed.
Read the full story