Efficient Matching of Some Fundamental Regular Expressions with Backreferences

📅 2025-04-25
📈 Citations: 0
Influential: 0
📄 PDF
🤖 AI Summary
This paper addresses the matching problem for regular expressions with back-references (REWB), focusing on the classical subclass $e_0 (e)_1 e_1 ackslash 1 e_2$, where $e_0, e, e_1, e_2$ are ordinary regular expressions. We propose the first quadratic-time matching algorithm for this subclass. Our approach innovatively integrates automata-theoretic techniques—specifically, injection and summarization—with string-algorithmic concepts—including right-maximal repetitions and extensible prefixes—to construct a bidirectional matching verification mechanism. This design overcomes the long-standing $O(n^3)$ time-complexity barrier inherent in prior algorithms. The resulting algorithm runs in $O(n^2)$ time, substantially improving upon the best-known cubic-time solutions. Moreover, the treated subclass captures many practically prevalent REWB patterns, ensuring both theoretical advancement and real-world applicability.

Technology Category

Application Category

📝 Abstract
Regular expression matching is of practical importance due to its widespread use in real-world applications. In practical use, regular expressions are often used with real-world extensions. Accordingly, the matching problem of regular expressions with real-world extensions has been actively studied in recent years, yielding steady progress. However, backreference, a popular extension supported by most modern programming languages such as Java, Python, JavaScript and others in their standard libraries for string processing, is an exception to this positive trend. In fact, it is known that the matching problem of regular expressions with backreferences (rewbs) is theoretically hard and the existence of an asymptotically fast matching algorithm for arbitrary rewbs seems unlikely. Even among currently known partial solutions, the balance between efficiency and generality remains unsatisfactory. To bridge this gap, we present an efficient matching algorithm for rewbs of the form $e_0 (e)_1 e_1 ackslash 1 e_2$ where $e_0, e, e_1, e_2$ are pure regular expressions, which are fundamental and frequently used in practical applications. It runs in quadratic time with respect to the input string length, substantially improving the best-known cubic time complexity for these rewbs. Our algorithm combines ideas from both stringology and automata theory in a novel way. We leverage two techniques from automata theory, injection and summarization, to simultaneously examine matches whose backreferenced substrings are either a fixed right-maximal repeat or its extendable prefixes, which are concepts from stringology. By further utilizing a subtle property of extendable prefixes, our algorithm correctly decides the matching problem while achieving the quadratic-time complexity.
Problem

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

Efficient matching for fundamental regex with backreferences
Improving cubic to quadratic time complexity for specific rewbs
Bridging efficiency-generality gap in backreference handling
Innovation

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

Combines stringology and automata theory
Uses injection and summarization techniques
Achieves quadratic time complexity
🔎 Similar Papers
No similar papers found.