Class RegexTools
Regular expression tools
Inheritance
Namespace: Textify.Tools
Assembly: Textify.dll
Syntax
public static class RegexTools
Methods
| Edit this page View SourceFilter(string, string)
Filters the string from the substrings matched by the given pattern
Declaration
public static string Filter(string text, string pattern)
Parameters
Type | Name | Description |
---|---|---|
string | text | The text to be processed |
string | pattern | Regular expression pattern for replacing |
Returns
Type | Description |
---|---|
string | Filtered text |
Filter(string, string, string)
Filters the string from the substrings matched by the given pattern
Declaration
public static string Filter(string text, string pattern, string replaceWith)
Parameters
Type | Name | Description |
---|---|---|
string | text | The text to be processed |
string | pattern | Regular expression pattern for replacing |
string | replaceWith | Replaces the matched substrings with the specified text |
Returns
Type | Description |
---|---|
string | Filtered text |
IsMatch(string, string)
Checks to see whether the pattern matches
Declaration
public static bool IsMatch(string text, string pattern)
Parameters
Type | Name | Description |
---|---|---|
string | text | The text to be matched |
string | pattern | Regular expression pattern for matching |
Returns
Type | Description |
---|---|
bool | True if there are matches. Otherwise, false |
IsValidRegex(string)
Determines whether the specified regular expression pattern is valid or not
Declaration
public static bool IsValidRegex(string pattern)
Parameters
Type | Name | Description |
---|---|---|
string | pattern | Specified pattern |
Returns
Type | Description |
---|---|
bool | True if valid; false otherwise |
IsValidRegex(Regex)
Determines whether the specified regular expression pattern is valid or not
Declaration
public static bool IsValidRegex(Regex pattern)
Parameters
Type | Name | Description |
---|---|---|
Regex | pattern | Specified pattern |
Returns
Type | Description |
---|---|
bool | True if valid; false otherwise |
Match(string, string)
Matches the pattern with the text given
Declaration
public static Match Match(string text, string pattern)
Parameters
Type | Name | Description |
---|---|---|
string | text | The text to be matched |
string | pattern | Regular expression pattern for matching |
Returns
Type | Description |
---|---|
Match | A System.Text.RegularExpressions.Match that contains information about the current match |
Matches(string, string)
Matches the pattern with the text given
Declaration
public static MatchCollection Matches(string text, string pattern)
Parameters
Type | Name | Description |
---|---|---|
string | text | The text to be matched |
string | pattern | Regular expression pattern for matching |
Returns
Type | Description |
---|---|
MatchCollection | Collection of System.Text.RegularExpressions.Matches that contains information about the current match |
ParseRegex(string)
Parses the regular expression pattern after validating it
Declaration
public static Regex ParseRegex(string pattern)
Parameters
Type | Name | Description |
---|---|---|
string | pattern | Specified pattern |
Returns
Type | Description |
---|---|
Regex | Regular expression instance of a valid regular expression pattern |
Split(string, string)
Splits the string using the matched substrings as the delimiters
Declaration
public static string[] Split(string text, string pattern)
Parameters
Type | Name | Description |
---|---|---|
string | text | The text to be split |
string | pattern | Regular expression pattern for splitting |
Returns
Type | Description |
---|---|
string[] | Array of strings |
TryParseRegex(string, out Regex?)
Parses the regular expression pattern after validating it
Declaration
public static bool TryParseRegex(string pattern, out Regex? result)
Parameters
Type | Name | Description |
---|---|---|
string | pattern | Specified pattern |
Regex | result | [out] Resultant regular expression instance |
Returns
Type | Description |
---|---|
bool | True if valid; false otherwise |