DigiNews

Tech Watch by Johan Denoyer

← Back to articles

Finding all regex matches has always been O(n²). even in the engines built to prevent it

Quality: 9/10 Relevance: 8/10

Summary

The article argues that finding all regex matches inherently requires quadratic time in the worst case for general regex patterns, even with engines designed to avoid backtracking. It discusses historical solutions like Aho-Corasick for fixed strings, Hyperscan's earliest-match approach, and introduces RE#'s two-pass algorithm that achieves true linear-time all-matches. Hardened mode further guarantees linear time but at performance trade-offs. It also touches streaming, captures limitations, and practical implications for real-world workloads.

🚀 Service construit par Johan Denoyer