On the computational complexity of JavaScript regex matching

📅 2026-03-27
📈 Citations: 0
Influential: 0
📄 PDF
🤖 AI Summary
This work rigorously establishes the computational complexity of JavaScript regular expression matching, a problem long lacking precise theoretical characterization. By integrating computational complexity theory with interactive theorem proving, the study formally demonstrates that the problem is PSPACE-hard and OptP-hard in its general form, and further proves it to be PSPACE-complete and OptP-complete under typical syntactic subsets. All core proofs have been mechanically verified using the Rocq proof assistant. These results provide a solid theoretical foundation for the performance optimization and security analysis of regular expression engines, offering critical insights into both practical implementation challenges and inherent computational limits.
📝 Abstract
Despite widespread use, the complexity class of modern regular expression matching was not well-understood. Previous work proved that regular expression matching with backreferences and lookarounds was PSPACE-complete, but the proof was not mechanized and applied to an abstract regex language. This paper clarifies the question for JavaScript regular expressions. In this paper, we prove the following new results, with most core proofs mechanized in the Rocq proof assistant. We prove that JavaScript regex matching is indeed PSPACE-hard, even without negative lookarounds, and OptP-hard as well; that JavaScript regex matching without lower-bounded quantifiers (i.e. quantifiers with a non-zero minimum number of repetitions) is PSPACE-complete; and that JavaScript regex matching without lower-bounded quantifiers and without lookarounds is OptP-complete.
Problem

Research questions and friction points this paper is trying to address.

computational complexity
JavaScript regex
PSPACE-hard
OptP-complete
regular expression matching
Innovation

Methods, ideas, or system contributions that make the work stand out.

JavaScript regex
computational complexity
PSPACE-hard
OptP-complete
mechanized proof
🔎 Similar Papers
No similar papers found.