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
- Implementing Regular Expressionsswtch.com
- 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
- GitHub - kyx0r/pikevm: Russ Cox/Rob Pike pikevm regex implementationgithub.com
- The Regular Expression Denial of Service (ReDoS) cheat-sheet | by James Davis | Level Up Codinglevelup.gitconnected.com
- Thompson's construction - Wikipediaen.wikipedia.org
- Regular expression - Wikipediaen.wikipedia.org
- Yes you should understand backprop | by Andrej Karpathy | Mediumkarpathy.medium.com
- NYSRGnotes.ekzhang.com
- Tristan's Site - Tristan Humethume.ca
- Reading 12: Regular Expressions & Grammarsweb.mit.edu
- Rewriting Bun in Rust | Bun Blogbun.com
- Fast regex search: indexing text for agent tools · Cursorcursor.com