Namespace: FluentRegex
Interface IBuilder
defines the methods and properties for building a regular expression pattern.
public interface IBuilder
Gets or sets the pattern.
public abstract StringBuilder Pattern { get; set; }
Builds the regular expression pattern.
object Build()
Returns the regular expression pattern as a string.
string ToString()
The AppendLiteral
method appends a literal string to the pattern, escaping any special characters.
object AppendLiteral(string literal)
literal
String
Validates the pattern to ensure it is well-formed. Each validation method contains explicit error messages which are thrown when the validation fails. This should help the user to understand what is wrong with the pattern, rather than just throwing a generic exception. However the final validation method checks that the pattern is a valid regular expression, and throws a generic exception if it is not, bubbling up the error message from the regular expression engine.
void Validate()
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.
void Validate(bool skipRegexValidation)
skipRegexValidation
Boolean
A Boolean value to skip the regular expression validation.
Validates the pattern to ensure it does not end with any characters that would cause an exception when building the regular expression.
void ValidateEnd()
Validates the pattern to ensure it does not start with any characters that would cause an exception when building the regular expression.
void ValidateStart()
Validates the pattern to ensure that the number of opening and closing parentheses match.
void ValidateParenthesesPairs()
Validates the pattern to ensure it does not contain empty structures. Including empty parentheses, empty non-capturing groups, and empty named capturing groups, empty Character classes.
void ValidateNoEmptyStructures()
Validates the pattern to ensure there are no unescaped characters that are not escapable.
void ValidateNoUnEscapedCharacters()
Dictionary<char, int> GetOpenCloseCharacterCounts()
int GetCountOfCharacter(char character, string pattern)
character
Char
pattern
String
bool OpenClosingCharacterCountsMatch(string pattern)
pattern
String
bool ParenthesesCountsAreEven()
bool SquareBracketCountsAreEven()
bool CurlyBraceCountsAreEven()
void CheckInvalidEscapedClosure(string pattern, Char[] closingCharacters)
pattern
String
closingCharacters
Char[]
Validates the pattern to ensure it is a valid regular expression.
void ValidatePatternRegex()