arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2504.18247cs.FLcs.DS
收藏

带反向引用的若干基础正则表达式的高效匹配

Efficient Matching of Some Fundamental Regular Expressions with Backreferences

Taisei Nogami, Tachio Terauchi

AI总结:

本文针对形式为$e_0 (e)_1 e_1 \ackslash 1 e_2$的基础带反向引用正则表达式,提出一种结合自动机注入与摘要化技术的新颖匹配算法,将已知三次时间复杂度改进为二次时间复杂度。

摘要:

正则表达式匹配因其在现实应用中的广泛使用而具有重要的实际意义。在实际使用中,正则表达式常常与真实世界的扩展功能一起使用。相应地,近年来带真实世界扩展的正则表达式匹配问题得到了积极研究,并取得了稳步进展。然而,反向引用这一被大多数现代编程语言(如Java、Python、JavaScript等)在其字符串处理标准库中广泛支持的流行扩展,却是这一积极趋势中的一个例外。事实上,已知带反向引用的正则表达式(rewbs)的匹配问题在理论上是困难的,并且似乎不太可能存在针对任意rewbs的渐近快速匹配算法。即使在目前已知的部分解决方案中,效率与通用性之间的平衡也仍然不能令人满意。为了弥合这一差距,我们针对形式为$e_0 (e)_1 e_1 \ackslash 1 e_2$的rewbs提出了一种高效匹配算法,其中$e_0, e, e_1, e_2$是纯正则表达式,这类表达式是基础性的,并在实际应用中被频繁使用。该算法相对于输入字符串长度以二次时间运行,大幅改善了这些rewbs目前已知的最优三次时间复杂度。我们的算法以一种新颖的方式结合了字符串学和自动机理论中的思想。我们利用自动机理论中的两种技术,即注入和摘要化,来同时检查那些被反向引用的子串要么是固定的右极大重复串,要么是其可扩展前缀的匹配,这些是来自字符串学的概念。通过进一步利用可扩展前缀的一个微妙性质,我们的算法在实现二次时间复杂度的同时,正确地判定匹配问题。

英文摘要:

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 \backslash 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.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑