In This Article

RegexHelper Class

Provides helper methods for working with regular expression patterns.

public static class RegexHelper
Inheritance:
object object

Methods

Escape(string)

Escapes all special characters in the specified regex search pattern.

public static string Escape(string pattern)
Parameter Type Description
pattern string

The search pattern to escape.

Returns

string:

The escaped pattern.

Escape(string, bool)

Escapes all special characters in the specified regex search or replace pattern.

public static string Escape(string pattern, bool isReplacePattern)
Parameter Type Description
pattern string

The pattern to escape.

isReplacePattern bool

Whether the pattern is a replace pattern.

Returns

string:

The escaped pattern.

IsPatternSpecialChar(char)

Returns whether the specified character is a search 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 find pattern special character; otherwise, false.

Validate(string, bool)

Validates the specified regular expression pattern.

public static void Validate(string pattern, bool allowCapturing)
Parameter Type Description
pattern string

The pattern to examine.

allowCapturing bool

Whether to allow capturing.

Remarks

An exception will be thrown if the pattern is invalid.

Validate(string, bool, HashSet<string>)

Validates the specified regular expression pattern and referenced lexical macros.

public static void Validate(string pattern, bool allowCapturing, HashSet<string> macroKeys)
Parameter Type Description
pattern string

The pattern to examine.

allowCapturing bool

Whether to allow capturing.

macroKeys HashSet<string>

The set of available lexical macro keys.

Remarks

An exception will be thrown if the pattern is invalid.

Inherited Members