Improved Extended Regular Expression Matching
arXiv:2510.09311
Abstract
An extended regular expression specifies a set of strings formed by characters from an alphabet combined with concatenation, union, intersection, complement, and star operators. Given an extended regular expression and a string , the extended regular expression matching problem is to decide if matches any of the strings specified by . Extended regular expression matching was introduced by Hopcroft and Ullman in the 1970s, who gave a simple dynamic programming solution using time and space, where is the length of and is the length of . The current state-of-the art solution, by Yamamoto and Miyazaki uses time and space, where is the number of negation and complement operators in and is the number of bits in a machine word. This roughly replaces the factor with in the dominant terms of both the space and time bounds of the classical Hopcroft and Ullman algorithm. In this paper, we present a new solution that solves extended regular expression matching in \[ O\left(n^ωk + \frac{n^2m}{\max(w/\log w, \log n)} + m\right) \] time and space, where is the exponent of matrix multiplication. Essentially, this replaces the dominant term with in the time bound, while simultaneously improving the term in the space to . Our results are based on a surprisingly simple combination of techniques and insights, including a compact representation to store and efficiently combine substring matches, a clustering technique for parse trees of extended regular expressions, and a new efficient combination of finite automaton simulation with our substring match representation to speed up the classic dynamic programming solution.