An additional non-backtracking RegExp engine · V8
v8.dev · 1,802 words · saved by 1 readers
V8 now has an additional RegExp engine that serves as a fallback and prevents many instances of catastrophic backtracking.
Starting with v8.8, V8 ships with a new experimental non-backtracking RegExp engine (in addition to the existing Irregexp engine ) which guarantees execution in linear time with respect to the size of the subject string. The experimental engine is available behind the feature flags mentioned below. Runtime of /(a*)*b/.exec('a'.repeat(n)) for n ≤ 100 Here’s how you can configure the new RegExp engine: --enable-experimental-regexp_engine-on-excessive-backtracks enables the fallback to the non-backtracking engine on excessive backtracks. --regexp-backtracks-before-fallback N (default N = 50,000)
saved by
related reading
- GitHub - google/re2: RE2 is a fast, safe, thread-friendly alternative to backtracking regular expression engines like those used in PCRE, Perl, and Python. It is a C++ library.github.com
- Fast regex search: indexing text for agent tools · Cursorcursor.com
- GitHub - kyx0r/pikevm: Russ Cox/Rob Pike pikevm regex implementationgithub.com
- Implementing Regular Expressionsswtch.com
- Recursive Language Models | Alex L. Zhangalexzhang13.github.io
- JIT Compiling Code in 5μsmalisper.me
- The Regular Expression Denial of Service (ReDoS) cheat-sheet | by James Davis | Level Up Codinglevelup.gitconnected.com
- Regular Expression Matching with a Trigram Indexswtch.com
- Beating the fastest lexer generator in Rustalic.dev
- Solving regex crosswords with Z3 - Made of Bugsblog.nelhage.com
- Regular expressions library (since C++11)en.cppreference.com
- Speculation in JavaScriptCore | WebKitwebkit.org