Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

O(m * n) lookaround #1153

rpjohnst started this conversation in General
Discussion options

A 2024 POPL paper proposed a new NFA-based algorithm for matching regular expressions with arbitrary lookaround in O(m * n) time, without the previously-required exponential blowup in automaton size or matching time: https://dl.acm.org/doi/10.1145/3632934

Its main limitation is that, for regular expressions with both lookahead and lookbehind, it no longer supports streaming, because each form of lookaround involves a pass from its associated direction, and an O(n) buffer to hold the results. (With only one or the other, everything can be done in one pass and without the buffer.)

They show some pretty competitive benchmarks with PCRE2 and Java's regex engine as well.

I don't personally have a way to judge how worthwhile this would be, but I thought you would be interested to hear about it in any case!

You must be logged in to vote

Replies: 1 comment

Comment options

An implementation of look-behinds with a streaming algorithm has been implemented and opened as a PR: #1266

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Converted from issue

This discussion was converted from issue #1152 on January 19, 2024 12:42.

AltStyle によって変換されたページ (->オリジナル) /