SearcharxivSearch

arXiv · 2609.16914

Improved Regular Expression Matching with Simple Backreferences

Abstract

A regular expression with backreferences (rewb) specifies a set of strings formed by characters combined with concatenation, union, star operators, and backreferences. A backreference consists of a capturing group $(\cdot)_i$ and a reference $\backslash i$. The substring matched by the reference must match the substring matched by the corresponding capturing group. Given a rewb $R$ and a string $Q$, the rewb matching problem is to decide whether $Q$ is one of the strings specified by $R$. In full generality, rewb matching is NP-complete, but efficient solutions exist for various subclasses. In the paper, we focus on rewb containing a single capturing group and $k$ references. For this class, Uezato~[CPM 2026] gave an $O((k n^2 m^2)$ time and $O(n^2m^2)$ space algorithm, where $m$ is the length of the regular expression $R$ and $n$ is the length of the string $Q$. For the special case of $k=1$, Nogami and Terauchi~[MFCS 2025] gave an $O(n^2m^2)$ time and $O(n+ m^2)$ space algorithm. On the other hand, Nogami, Nakamura, and Terauchi~[arXiv 2026] gave a conditional lower bound, showing that we cannot solve the problem in $O(n^{2-ε} \mathrm{poly}(m))$ for any $ε> 0$ assuming the orthogonal vector hypothesis. Our main result is a new algorithm that runs in $O(n^2m)$ time and uses $O(nm)$ space. This improves the above results (by a factor of $km$ and $m$, respectively) and the former's space bound (by a factor of $nm$). We also show how to extend our algorithm to handle a slightly more general class of ordered and single-nested rewbs.

Explore related subjects

Keep this discovery

Explore connections, maps & timelines

BibTeXRIS

Philip Bille, Inge Li Gørtz, Rikke Schjeldrup Jessen. 2026-09-15. Improved Regular Expression Matching with Simple Backreferences. https://arxiv.org/abs/2609.16914

Cite the original work for its findings. Save a collection to share your selection of sources.

KEEP EXPLORING

Related papers

Online Flexible Busy Time Scheduling on Heterogeneous Machines

We study the online busy time scheduling model on heterogeneous machines. In our setting, jobs with uniform processing time arrive online with a deadline that becomes known to the algorithm at the job's arrival time. An algorithm has access to machines, each with different associated capacities and costs. The goal is to schedule jobs on machines by their deadline, so that the total cost incurred by the scheduling algorithm is minimized. While busy time scheduling has been well-studied, relatively little is known when machines are heterogeneous (i.e., have different costs and capacities), despite this natural theoretical generalization being the most practical model for clients using cloud computing services. We make significant progress in understanding this model by designing a deterministic online algorithm with competitive ratio 8(2p-1)/p < 16 when all jobs have uniform processing time p. A randomized version of this algorithm is 4(2p-1)/(p \ln 2)-competitive against an oblivious adversary. For unit-processing-time jobs, we give lower bounds of 4 and e (where e is Euler's number) on the competitive ratio of deterministic and randomized online algorithms, respectively. For unit-processing-time jobs with agreeable deadlines, we provide a deterministic 2-competitive online algorithm and a matching lower bound.

cs.DS

The Semi-Oblivious Cup Game: an Imperfect Information Setting

In the cup game, an adversary distributes $1$ unit of water among $n$ initially empty cups during each time step. The player then selects a single cup from which to remove up to $1$ unit of water, with the goal of minimizing the backlog, i.e., the supremum of the height of the fullest cup over all time steps. In the cup flushing game, the player is additionally allowed to empty the chosen cup entirely. Past work has shown that the optimal backlog in both of these settings is $Θ(\log n)$. Furthermore, the \textbf{greedy} algorithm, which always removes water from the fullest cup, has been shown in previous work to be exactly optimal in both the cup game and the cup flushing game. We introduce a new model, the semi-oblivious cup game, in which the player is uncertain of the exact height of each cup. We analyze the performance of the \textbf{greedy} algorithm in this setting, which can be viewed as selecting an arbitrary cup within a constant multiplicative factor of the fullest cup. We prove matching upper and lower bounds showing that the \textbf{greedy} algorithm achieves a backlog of $Θ(n^{\frac{c-1}{c}})$ in the semi-oblivious cup game. We also establish matching upper and lower bounds of $2^{Θ(\sqrt{\log n})}$ in the semi-oblivious cup flushing game. Finally, we show that in an additive error setting, greedy is actually able to achieve backlog $Θ(\log n)$, via matching upper and lower bounds. All of our lower bounds apply for adaptive adversaries against any (even randomized) algorithm, proving that greedy is asymptotically optimal in the semi-oblivious model.

cs.DS

The Binary Tree Mechanism is Optimal for Differentially Private Continual Counting

Private continual counting is a fundamental problem in differential privacy: given a binary stream of length $n$, where each $1$ corresponds to the contribution of one individual, the goal is to release all running counts while protecting the privacy of each individual. For fixed privacy parameters, the standard binary tree mechanism achieves expected $\ell_\infty$ error $O(\log^{3/2} n)$ under approximate differential privacy and $O(\log^2 n)$ under pure differential privacy. Whether these dependences on the stream length are necessary has remained a central open problem. For fixed $\varepsilon\in(0,1)$, we prove a lower bound of $Ω(\log^{3/2} n)$ under approximate DP with sufficiently small fixed $δ>0$, and a lower bound of $Ω(\log^2 n)$ under pure DP. These bounds establish the optimality of the binary tree mechanism in both settings. The bounds hold for arbitrary mechanisms, even when the entire stream is available in advance. Both proofs use the same decomposition and accumulation of residual noise along a tree. As a consequence of the approximate-DP bound, we also obtain a largest-possible separation between hereditary discrepancy and private $\ell_\infty$ error for linear queries, showing that the known general upper bound in terms of hereditary discrepancy has the optimal dependence on the number of queries.

cs.DS