A regular expression specifies a set of strings formed by single characters combined with concatenation, union, and Kleene star operators. Given a regular expression $R$ and a string $Q$, the classic regular expression matching problem is to decide whether $Q$ matches any string specified by $R$. Let $m$ and $n$ be the lengths of $R$ and $Q$, respectively. Our main result is a new algorithm that, given a parameter $t \geq m$, solves the problem in \[ O\left(\frac{nm\,\lg\lg(t/m)}{\lg^2(t/m)}+t+n\right) \] time and $O(t)$ words of space. In particular, for any fixed $0<\eps<1$, when $m\leq n^{1-\eps}$, we solve the problem in $O(nm \lg \lg n/\lg^2 n + m + n)$ time and $O(n)$ space. Compared to the previous best result [Bille and Thorup, ICALP 2009], this improves the leading term by a factor $\sqrt{\lg n}/\lg\lg n$. The key new technique is a two-dimensional tabulation specialized to the regular expression.
翻译:暂无翻译