A comprehensive benchmark analysis compares regex matching performance across four major language/library ecosystems: C++ standard library, PCRE2, Go standard library, and Python standard library. The study also evaluates a novel Go code generation tool, regexp2go, which compiles regex patterns into native Go code for potential speed gains. Tests were conducted with Python 3.14.6 and other up-to-date versions. Key findings reveal significant performance differences, with PCRE2 often leading in raw speed, while Go's standard library offers a balanced trade-off. The data helps developers make informed decisions for regex-heavy applications like log parsing, data validation, and text processing. The benchmark methodology is reproducible, making it a valuable reference for performance engineers.
A detailed benchmark comparing regex performance across C++, PCRE2, Go, and Python, including a Go code generation approach.