Regular expressions are widely used in software. Various regular expression engines support different combinations of extensions to classical regular constructs such as Kleene star, concatenation, nondeterministic choice (union in terms of match semantics). The extensions include e.g. anchors, lookarounds, counters, backreferences. The properties of combinations of such extensions have been subject of active recent research. In the current paper we present a symbolic derivatives based approach to finding matches to regular expressions that, in addition to the classical regular constructs, also support complement, intersection and lookarounds (both negative and positive lookaheads and lookbacks). The theory of computing symbolic derivatives and determining nullability given an input string is presented that shows that such a combination of extensions yields a match semantics that corresponds to an effective Boolean algebra, which in turn opens up possibilities of applying various Boolean logic rewrite rules to optimize the search for matches. In addition to the theoretical framework we present an implementation of the combination of extensions to demonstrate the efficacy of the approach accompanied with practical examples.
翻译:正则表达式广泛应用于软件领域。各种正则表达式引擎支持对经典正则构造(如Kleene星、连接、非确定性选择,在匹配语义中对应并集)的不同组合的扩展。这些扩展包括锚点、环视、计数器和反向引用等。此类扩展组合的性质已成为近期活跃研究课题。本文提出一种基于符号导数的方法,用于寻找正则表达式的匹配项,该方法除支持经典正则构造外,还支持补集、交集和环视(包括正负向前瞻和正负向后瞻)。本文给出了针对给定输入字符串计算符号导数并确定可空性的理论,表明这种扩展组合产生的匹配语义对应于有效的布尔代数,进而为应用各种布尔逻辑重写规则优化匹配搜索提供了可能。除理论框架外,本文还给出了该扩展组合的实现,通过实践案例展示了该方法的有效性。