In This Article

MatchingRegexCode Class

Implements regular expression engine code that can execute match logic.

public class MatchingRegexCode : RegexCodeBase
Inheritance:
object RegexCodeBase object

Properties

CaptureCount

The number of capture groups available to replacement patterns, including the implicit full-match capture at index 0.

public int CaptureCount { get; }

Property Value

int

Methods

Create(string, MatchingRegexOptions?)

Creates a MatchingRegexCode instance.

public static MatchingRegexCode Create(string pattern, MatchingRegexOptions? options = null)
Parameter Type Description
pattern string

A text regular expression pattern.

options MatchingRegexOptions

The optional MatchingRegexOptions specifying options.

Returns

MatchingRegexCode

EscapePattern(string?)

Escapes all special characters in the specified pattern.

public static string? EscapePattern(string? pattern)
Parameter Type Description
pattern string

The pattern to escape.

Returns

string:

The escaped pattern.

GetCaptures(ISimpleTextBufferReader)

Returns the list of captures, if any, after attempting to match the regular expression at the current offset within the specified text buffer.

public IList<RegexCapture>? GetCaptures(ISimpleTextBufferReader reader)
Parameter Type Description
reader ISimpleTextBufferReader

The ISimpleTextBufferReader to use for reading text. The reader's current offset must be pre-initialized to where reading should begin.

Returns

IList<RegexCapture>:

The list of captures, if a match was successful. If the no match occurred, a null value is returned.

GetStartsWithCharClass()

Returns the CharClass containing characters that can start matching the regular expression, if able to be determined.

public CharClass? GetStartsWithCharClass()

Returns

CharClass:

The CharClass containing characters that can start matching the regular expression; null if it cannot be determined.

Remarks

The CharClass from this method can be used as an optimization to determine if the next character in a reader can possibly start a match with the regular expression. If not, an attempt to match can be skipped.

IsPatternSpecialChar(char)

Returns whether the specified character is a pattern special character.

public static bool IsPatternSpecialChar(char ch)
Parameter Type Description
ch char

The character to examine.

Returns

bool:

true if the specified character is a pattern special character; otherwise, false.

Match(ISimpleTextBufferReader)

Attempts to match the regular expression at the current offset within the specified text buffer.

public MatchType Match(ISimpleTextBufferReader reader)
Parameter Type Description
reader ISimpleTextBufferReader

The ISimpleTextBufferReader to use for reading text. The reader's current offset must be pre-initialized to where reading should begin.

Returns

MatchType:

A MatchType indicating the type of match that was made.

Inherited Members

Extension Methods