FluentRegex

Builder

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 ObjectBuilder
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.

Properties

Pattern

public abstract StringBuilder Pattern { get; set; }

Property Value

StringBuilder

Methods

StartAnchor()

Adds an anchor to the pattern.

public abstract AnchorBuilder StartAnchor()

Returns

AnchorBuilder

StartCharacterClass()

Adds a character class to the pattern.

public abstract CharacterClassBuilder StartCharacterClass()

Returns

CharacterClassBuilder

Build()

Builds the regular expression pattern.

public abstract object Build()

Returns

Object

ToString()

The ToString method returns the current value of the pattern as a string.

public string ToString()

Returns

String

Times(Int32, Int32)

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)

Parameters

minimum Int32

maximum Int32

Returns

Object

Lazy()

The Lazy method appends a lazy quantifier (?) to the pattern.

public object Lazy()

Returns

Object

OneOrMore()

The OneOrMore method appends a one or more quantifier (+) to the pattern.

public object OneOrMore()

Returns

Object

ZeroOrMore()

The ZeroOrMore method appends a zero or more quantifier (*) to the pattern.

public object ZeroOrMore()

Returns

Object

ZeroOrOne()

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()

Returns

Object

Or()

The Or method appends an alternation operator (|) to the pattern.

public object Or()

Returns

Object

StartGroup()

Adds a GroupBuilder to the pattern.

public GroupBuilder StartGroup()

Returns

GroupBuilder
GroupBuilder

CaptureGroup()

Adds a GroupBuilder to the pattern.

public GroupBuilder CaptureGroup()

Returns

GroupBuilder
GroupBuilder

NonCaptureGroup()

Adds a GroupBuilder to the pattern.

public GroupBuilder NonCaptureGroup()

Returns

GroupBuilder

NamedCaptureGroup(NamedGroupStyle, String)

Adds a GroupBuilder to the pattern.

public GroupBuilder NamedCaptureGroup(NamedGroupStyle namedGroupStyle, string groupName)

Parameters

namedGroupStyle NamedGroupStyle

groupName String

Returns

GroupBuilder

Validate(Boolean)

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)

Parameters

skipRegexValidation Boolean
A Boolean value to skip the regular expression validation.

Validate()

public void Validate()