re2 0.2.0
re2: ^0.2.0 copied to clipboard
Linear-time regular expressions for Dart via Google's RE2 over FFI. Immune to catastrophic backtracking (ReDoS).
0.2.0 #
- Add
replaceAllandreplaceFirst, the linear-time counterparts toString.replaceAll(RegExp(...), ...). Because RE2 cannot backtrack, running a substitution over untrusted input or with a user-supplied pattern cannot hang the isolate. The rewrite string can reference capture groups with\1..\9.
0.1.0 #
Initial release, vendoring RE2 (last revision before the Abseil dependency).
Re2: compile a pattern once, thenhasMatch,firstMatch,stringMatch, andallMatches, withcaseSensitive,multiLine, anddotAllflags.Re2Match: positional and named group access.- Linear-time matching: catastrophic-backtracking patterns that hang
dart:coreRegExpstay linear here. - Backreferences and lookaround throw
FormatExceptionat construction, since RE2 does not support them. - Native code builds automatically via Dart build hooks (Dart 3.10+).