literal method
======================================================================== LITERALS
Appends an expression to find the literal expression
Example: var regex = FluentRegex().literal('abc'); expect(regex.hasMatch('abc12'), true); expect(regex.hasMatch('12abc34'), true); expect(regex.hasMatch('12ab34'), false);
Implementation
FluentRegex literal(String literal,
[Quantity quantity = const Quantity.oneTime()]) {
if (literal.length == 1 || quantity == Quantity.oneTime()) {
var newExpression = _expression + escape(literal) + quantity.toString();
return FluentRegex._copyWith(this, expression: newExpression);
} else {
return group(FluentRegex(escape(literal)), quantity: quantity);
}
}