C# Class Patterns.Text.RegularExpressions.CompiledRegex

Provides a Regex implementation that is easier to instantiate.
Instances of the CompiledRegex type are always "compiled"; that is, their RegexOptions always include the RegexOptions.Compiled option.
Inheritance: System.Text.RegularExpressions.Regex
Show file Open project: patterns-group/code-patterns Class Usage Examples

Public Methods

Method Description
BuildFrom ( string text, RegexOptions options = RegexOptions.None ) : CompiledRegex

Builds a new CompiledRegex instance from the specified raw text. Reserved characters are automatically escaped, causing them to serve as required components of the resulting pattern. Whitespace is always interpreted to be of variable length (i.e. all contiguous whitespace blocks are replaced with the \s+ search term). Useful in scenarios were existing text is used to match against other values.

CompiledRegex ( string pattern, RegexOptions options = RegexOptions.None ) : System

Initializes a new instance of the CompiledRegex class.

DictionaryMatch ( string input, bool removeSystemGroups = true ) : string>.IDictionary

Gets the first pattern match as a key-value dictionary. Useful with patterns that use named groups.

DictionaryMatches ( string input, bool removeSystemGroups = true ) : string>>.IEnumerable

Gets the pattern matches as key-value dictionaries. Useful with patterns that use named groups.

Private Methods

Method Description
CompiledRegex ( ) : System
ConvertMatchToDictionary ( Match match, bool removeSystemGroups ) : string>.IDictionary
GetOptions ( RegexOptions originalOptions ) : RegexOptions
IsSystemGroup ( string>.KeyValuePair pair ) : bool

Method Details

BuildFrom() public static method

Builds a new CompiledRegex instance from the specified raw text. Reserved characters are automatically escaped, causing them to serve as required components of the resulting pattern. Whitespace is always interpreted to be of variable length (i.e. all contiguous whitespace blocks are replaced with the \s+ search term). Useful in scenarios were existing text is used to match against other values.
public static BuildFrom ( string text, RegexOptions options = RegexOptions.None ) : CompiledRegex
text string The raw text.
options RegexOptions The options (optional).
return CompiledRegex

CompiledRegex() public method

Initializes a new instance of the CompiledRegex class.
public CompiledRegex ( string pattern, RegexOptions options = RegexOptions.None ) : System
pattern string The regular expression.
options RegexOptions The options (optional).
return System

DictionaryMatch() public method

Gets the first pattern match as a key-value dictionary. Useful with patterns that use named groups.
public DictionaryMatch ( string input, bool removeSystemGroups = true ) : string>.IDictionary
input string The input.
removeSystemGroups bool True to remove system-added groups (such as group "0", "1", etc.) /// before extracting dictionary values. The default is true.
return string>.IDictionary

DictionaryMatches() public method

Gets the pattern matches as key-value dictionaries. Useful with patterns that use named groups.
public DictionaryMatches ( string input, bool removeSystemGroups = true ) : string>>.IEnumerable
input string The input.
removeSystemGroups bool True to remove system-added groups (such as group "0") before extracting /// dictionary values. The default is true.
return string>>.IEnumerable