Skip to content
pubscout

recursive_regex

1.0.0, released 6 years ago by jamesalex.dev

RegExp implementation that matches delimited text blocks recursively.

WASM-ready
$ flutter pub add recursive_regex
Source repository

What it does

Provides a RegExp‑like class that isolates text between start and end delimiters and returns each block as a match. It can operate globally, filter by surrounding patterns, and capture named groups inside the delimiters.

AI-written summary of version 1.0.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to extract or process nested bracket‑like structures (e.g., XML‑like tags).
  • You require pre‑ or post‑pattern constraints on matched blocks.

Skip it when

  • The input has no nested delimiters (plain RegExp is faster).
  • Performance is critical for large texts (this implementation is slower).
  • You need full regular‑expression features beyond delimiter matching.

Strengths

  • Handles arbitrarily nested delimiters correctly.
  • Supports prepended, appended, and inverse match filters.
  • Provides named capture groups inside delimiters.

Weaknesses

  • Not optimized for simple, non‑nested strings.
  • Limited to delimiter‑based matching; not a full parser.

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
1
import 'package:recursive_regex/recursive_regex.dart';

final regex = RecursiveRegex(
  startDelimiter: RegExp(r'<'),
  endDelimiter: RegExp(r'>'),
  global: true,
);
final input = '<a<b<c><d>>>';
print(regex.allMatches(input)); // ['<c>', '<d>', '<b<c><d>>', '<a<b<c><d>>>']

Alternatives

Packages that do the same job and could replace recursive_regex.

  • petitparser

    A general‑purpose parser combinator library that can also handle nested structures with more control.