English

Hardness of Regular Expression Matching with Extensions

Computational Complexity 2026-04-03 v3 Data Structures and Algorithms Formal Languages and Automata Theory

Abstract

The regular expression matching problem asks whether a given regular expression of length mm matches a given string of length nn. As is well known, the problem can be solved in O(nm)O(nm) time using Thompson's algorithm. Moreover, recent studies have shown that regular expression matching extended with a practical extension called lookaround can be solved in the same time complexity. In this work, we consider four well-known extensions to regular expressions called backreference, squaring, intersection and complement. We prove a number of novel time complexity lower bounds for regular expression matching with these extensions under the Orthogonal Vectors Conjecture (OVC), kk-OVC, kk-Clique Hypothesis, and Combinatorial kk-Clique Hypothesis. Some highlights of our results include the fact that none of the matching problems with the extensions can be solved in n2εpoly(m)n^{2-\varepsilon} \mathrm{poly}(m) time for any constant ε>0\varepsilon > 0 (for backreference, even when restricted to one capturing group) under OVC, and that the problem with complement, also known as extended regular expression (ERE) matching, cannot be solved in time n2εtower(o(m))n^{2-\varepsilon}\mathrm{tower}(o(\sqrt{m})) under OVC, nωεtower(o(m))n^{\omega-\varepsilon}\mathrm{tower}(o(\sqrt{m})) under the kk-Clique Hypothesis (where ω\omega is the matrix multiplication exponent), and n3εtower(o(m))n^{3-\varepsilon}\mathrm{tower}(o(\sqrt{m})) under the Combinatorial kk-Clique Hypothesis, respectively. In particular, the latter two results show that the O(n3m)O(n^3 m)-time ERE matching algorithm introduced by Hopcroft and Ullman in 1979 and recently improved by Bille, G{\o}rtz and Jessen to run in O(nωm)O(n^\omega m) time using fast matrix multiplication was already optimal in a sense, and shed light on why the theoretical computer science community has struggled to improve the time complexity of ERE matching with respect to nn and mm for more than 45 years.

Keywords

Cite

@article{arxiv.2601.03020,
  title  = {Hardness of Regular Expression Matching with Extensions},
  author = {Taisei Nogami and Yoshiki Nakamura and Tachio Terauchi},
  journal= {arXiv preprint arXiv:2601.03020},
  year   = {2026}
}
R2 v1 2026-07-01T08:52:38.964Z