BackReference class

A reference to an existing Captured Group.

Given an expression that already includes a Captured Group somewhere within the expression, and it's not 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(),
            ],
          ),
        ),
      ),
      RawExpression(">",),
      MatchZeroOrMore(
        CharacterClass.any(),
      ),
      RawExpression("<",),
      CharacterClass.literal("/",),
      BackReference(1,),
      RawExpression(">",),
    ],
  ),
);
// produces <([a-z]+)>.*<\/\1>
exp.hasMatch("<html>Hello Za Warudo</html>",);
Implemented types
Available Extensions

Constructors

BackReference(int groupReference)
Creates an expression that indicates a groupReference by index where the number indicates the index number of created Capturing Group.
const

Properties

groupReference int
final
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

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