NamedBackReference class
A reference to an existing Captured Group.
Given an expression that already includes a Captured Group somewhere within the expression, and it's using a name, and not flagged as non-capturing, it is possible to "remember" it, and "echo" it once again elsewhere in the expression body, just like a variable.
Example:
import 'package:fancy_regex/fancy_regex.dart';
// Simple HTML-like tag matcher
RegExp exp = FancyRegex(
expression: const SerialExpressions(
[
RawExpression("<",),
CaptureGroup(
MatchOneOrMore(
CharacterGroup(
[
CharacterGroupRange.lowerCased(),
],
),
),
name: "tag_open",
),
RawExpression(">",),
MatchZeroOrMore(
CharacterClass.any(),
),
RawExpression("<",),
CharacterClass.literal("/",),
NamedBackReference("tag_open",),
RawExpression(">",),
],
),
);
// produces <(?<tag_open>[a-z]+)>.*<\/\k<tag_open>>
exp.hasMatch("<html>Hello Za Warudo</html>",);
- Implemented types
- Available Extensions
Constructors
- NamedBackReference(String name)
-
Creates an expression that indicates a reference by name should "echo"
the same expression stated by an existing preceding captured group that
declares the same name
const
Properties
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited