Namespace: FluentRegex
The Builder
class is the base class for all builders in the FluentRegex library. It contains methods for building regular expression patterns, and for validating the pattern to ensure it is well-formed.
public abstract class Builder : IBuilder
Inheritance Object → Builder
Implements IBuilder
Remarks:
The use of @dynamic as the return type for the methods in this class allows the methods to be called from any of the derived classes without needing to cast the return value or override the method in each class.
public abstract StringBuilder Pattern { get; set; }
Adds an anchor to the pattern.
public abstract AnchorBuilder StartAnchor()
Adds a character class to the pattern.
public abstract CharacterClassBuilder StartCharacterClass()
Builds the regular expression pattern.
public abstract object Build()
The ToString
method returns the current value of the pattern as a string.
public string ToString()
The Times
method appends a quantifier to the pattern. The method can take two parameters, and .
If both parameters are -1, the method appends an empty string. If is 0 and is -1, the method appends an asterisk.
If is 1 and is -1, the method appends a plus.
If is 0 and is 1, the method appends a question mark.
If is equal to , the method appends the minimum value in curly braces.
If is -1 and is not -1, the method appends the maximum value in curly braces.
If is -1 and is not -1, the method appends the minimum value in curly braces.
If both and are not -1, the method appends the minimum and maximum values in curly braces.
public object Times(int minimum, int maximum)
minimum
Int32
maximum
Int32
The Lazy
method appends a lazy quantifier (?
) to the pattern.
public object Lazy()
The OneOrMore
method appends a one or more quantifier (+
) to the pattern.
public object OneOrMore()
The ZeroOrMore
method appends a zero or more quantifier (*
) to the pattern.
public object ZeroOrMore()
The ZeroOrOne
method appends a zero or one quantifier (?
) to the pattern. The zero or one quantifier is equivalent to the regular expression {0,1}
, and shares a character with the lazy quantifier.
public object ZeroOrOne()
The Or
method appends an alternation operator (|
) to the pattern.
public object Or()
Adds a GroupBuilder to the pattern.
public GroupBuilder StartGroup()
Adds a GroupBuilder to the pattern.
public GroupBuilder CaptureGroup()
Adds a GroupBuilder to the pattern.
public GroupBuilder NonCaptureGroup()
Adds a GroupBuilder to the pattern.
public GroupBuilder NamedCaptureGroup(NamedGroupStyle namedGroupStyle, string groupName)
namedGroupStyle
NamedGroupStyle
groupName
String
Validates the pattern to ensure it does not end with any characters that would cause an exception when building the regular expression. Allows the user to skip the regular expression validation.
public void Validate(bool skipRegexValidation)
skipRegexValidation
Boolean
A Boolean value to skip the regular expression validation.
public void Validate()