class Regex

in global :: System . Text . RegularExpressions

Represents an immutable regular expression.


public Regex( string pattern )

Initializes a new instance of the class for the specified regular expression.

  • pattern The regular expression pattern to match.

public Regex( string pattern, RegexOptions options )

Initializes a new instance of the class for the specified regular expression, with options that modify the pattern.

  • pattern The regular expression pattern to match.
  • options A bitwise combination of the enumeration values that modify the regular expression.

public Regex( string pattern, RegexOptions options, TimeSpan matchTimeout )

Initializes a new instance of the class for the specified regular expression, with options that modify the pattern and a value that specifies how long a pattern matching method should attempt a match before it times out.

  • pattern The regular expression pattern to match.
  • options A bitwise combination of the enumeration values that modify the regular expression.
  • matchTimeout A time-out interval, or to indicate that the method should not time out.

public static int CacheSize { get; set; }

Gets or sets the maximum number of entries in the current static cache of compiled regular expressions.

  • Returns The maximum number of entries in the static cache.

public static string Escape( string str )

Escapes a minimal set of characters (\, *, +, ?, |, {, [, (,), ^, $, ., #, and white space) by replacing them with their escape codes. This instructs the regular expression engine to interpret these characters literally rather than as metacharacters.

  • str The input string that contains the text to convert.
  • Returns A string of characters with metacharacters converted to their escaped form.

public string GroupNameFromNumber( int i )

Gets the group name that corresponds to the specified group number.

  • i The group number to convert to the corresponding group name.
  • Returns A string that contains the group name associated with the specified group number. If there is no group name that corresponds to , the method returns .

public int GroupNumberFromName( string name )

Returns the group number that corresponds to the specified group name.

  • name The group name to convert to the corresponding group number.
  • Returns The group number that corresponds to the specified group name, or -1 if is not a valid group name.

public static TimeSpan InfiniteMatchTimeout

Specifies that a pattern-matching operation should not time out.

public bool IsMatch( string input )

Indicates whether the regular expression specified in the constructor finds a match in a specified input string.

  • input The string to search for a match.
  • Returns if the regular expression finds a match; otherwise, .

public bool IsMatch( string input, int startat )

Indicates whether the regular expression specified in the constructor finds a match in the specified input string, beginning at the specified starting position in the string.

  • input The string to search for a match.
  • startat The character position at which to start the search.
  • Returns if the regular expression finds a match; otherwise, .

public static bool IsMatch( string input, string pattern )

Indicates whether the specified regular expression finds a match in the specified input string.

  • input The string to search for a match.
  • pattern The regular expression pattern to match.
  • Returns if the regular expression finds a match; otherwise, .

public static bool IsMatch( string input, string pattern, RegexOptions options )

Indicates whether the specified regular expression finds a match in the specified input string, using the specified matching options.

  • input The string to search for a match.
  • pattern The regular expression pattern to match.
  • options A bitwise combination of the enumeration values that provide options for matching.
  • Returns if the regular expression finds a match; otherwise, .

public static bool IsMatch( string input, string pattern, RegexOptions options, TimeSpan matchTimeout )

Indicates whether the specified regular expression finds a match in the specified input string, using the specified matching options and time-out interval.

  • input The string to search for a match.
  • pattern The regular expression pattern to match.
  • options A bitwise combination of the enumeration values that provide options for matching.
  • matchTimeout A time-out interval, or to indicate that the method should not time out.
  • Returns if the regular expression finds a match; otherwise, .

public Match Match( string input )

Searches the specified input string for the first occurrence of the regular expression specified in the constructor.

  • input The string to search for a match.
  • Returns An object that contains information about the match.

public Match Match( string input, int startat )

Searches the input string for the first occurrence of a regular expression, beginning at the specified starting position in the string.

  • input The string to search for a match.
  • startat The zero-based character position at which to start the search.
  • Returns An object that contains information about the match.

public Match Match( string input, int beginning, int length )

Searches the input string for the first occurrence of a regular expression, beginning at the specified starting position and searching only the specified number of characters.

  • input The string to search for a match.
  • beginning The zero-based character position in the input string that defines the leftmost position to be searched.
  • length The number of characters in the substring to include in the search.
  • Returns An object that contains information about the match.

public static Match Match( string input, string pattern )

Searches the specified input string for the first occurrence of the specified regular expression.

  • input The string to search for a match.
  • pattern The regular expression pattern to match.
  • Returns An object that contains information about the match.

public static Match Match( string input, string pattern, RegexOptions options )

Searches the input string for the first occurrence of the specified regular expression, using the specified matching options.

  • input The string to search for a match.
  • pattern The regular expression pattern to match.
  • options A bitwise combination of the enumeration values that provide options for matching.
  • Returns An object that contains information about the match.

public static Match Match( string input, string pattern, RegexOptions options, TimeSpan matchTimeout )

Searches the input string for the first occurrence of the specified regular expression, using the specified matching options and time-out interval.

  • input The string to search for a match.
  • pattern The regular expression pattern to match.
  • options A bitwise combination of the enumeration values that provide options for matching.
  • matchTimeout A time-out interval, or to indicate that the method should not time out.
  • Returns An object that contains information about the match.

public MatchCollection Matches( string input )

Searches the specified input string for all occurrences of a regular expression.

  • input The string to search for a match.
  • Returns A collection of the objects found by the search. If no matches are found, the method returns an empty collection object.

public MatchCollection Matches( string input, int startat )

Searches the specified input string for all occurrences of a regular expression, beginning at the specified starting position in the string.

  • input The string to search for a match.
  • startat The character position in the input string at which to start the search.
  • Returns A collection of the objects found by the search. If no matches are found, the method returns an empty collection object.

public static MatchCollection Matches( string input, string pattern )

Searches the specified input string for all occurrences of a specified regular expression.

  • input The string to search for a match.
  • pattern The regular expression pattern to match.
  • Returns A collection of the objects found by the search. If no matches are found, the method returns an empty collection object.

public static MatchCollection Matches( string input, string pattern, RegexOptions options )

Searches the specified input string for all occurrences of a specified regular expression, using the specified matching options.

  • input The string to search for a match.
  • pattern The regular expression pattern to match.
  • options A bitwise combination of the enumeration values that specify options for matching.
  • Returns A collection of the objects found by the search. If no matches are found, the method returns an empty collection object.

public static MatchCollection Matches( string input, string pattern, RegexOptions options, TimeSpan matchTimeout )

Searches the specified input string for all occurrences of a specified regular expression, using the specified matching options and time-out interval.

  • input The string to search for a match.
  • pattern The regular expression pattern to match.
  • options A bitwise combination of the enumeration values that specify options for matching.
  • matchTimeout A time-out interval, or to indicate that the method should not time out.
  • Returns A collection of the objects found by the search. If no matches are found, the method returns an empty collection object.

public TimeSpan MatchTimeout { get; }

Gets the time-out interval of the current instance.

  • Returns The maximum time interval that can elapse in a pattern-matching operation before a is thrown, or if time-outs are disabled.

public RegexOptions Options { get; }

Gets the options that were passed into the constructor.

  • Returns One or more members of the enumeration that represent options that were passed to the constructor

public string Replace( string input, string replacement )

In a specified input string, replaces all strings that match a regular expression pattern with a specified replacement string.

  • input The string to search for a match.
  • replacement The replacement string.
  • Returns A new string that is identical to the input string, except that the replacement string takes the place of each matched string. If the regular expression pattern is not matched in the current instance, the method returns the current instance unchanged.

public string Replace( string input, string replacement, int count )

In a specified input string, replaces a specified maximum number of strings that match a regular expression pattern with a specified replacement string.

  • input The string to search for a match.
  • replacement The replacement string.
  • count The maximum number of times the replacement can occur.
  • Returns A new string that is identical to the input string, except that the replacement string takes the place of each matched string. If the regular expression pattern is not matched in the current instance, the method returns the current instance unchanged.

public string Replace( string input, string replacement, int count, int startat )

In a specified input substring, replaces a specified maximum number of strings that match a regular expression pattern with a specified replacement string.

  • input The string to search for a match.
  • replacement The replacement string.
  • count Maximum number of times the replacement can occur.
  • startat The character position in the input string where the search begins.
  • Returns A new string that is identical to the input string, except that the replacement string takes the place of each matched string. If the regular expression pattern is not matched in the current instance, the method returns the current instance unchanged.

public static string Replace( string input, string pattern, string replacement )

In a specified input string, replaces all strings that match a specified regular expression with a specified replacement string.

  • input The string to search for a match.
  • pattern The regular expression pattern to match.
  • replacement The replacement string.
  • Returns A new string that is identical to the input string, except that the replacement string takes the place of each matched string. If is not matched in the current instance, the method returns the current instance unchanged.

public static string Replace( string input, string pattern, string replacement, RegexOptions options )

In a specified input string, replaces all strings that match a specified regular expression with a specified replacement string. Specified options modify the matching operation.

  • input The string to search for a match.
  • pattern The regular expression pattern to match.
  • replacement The replacement string.
  • options A bitwise combination of the enumeration values that provide options for matching.
  • Returns A new string that is identical to the input string, except that the replacement string takes the place of each matched string. If is not matched in the current instance, the method returns the current instance unchanged.

public static string Replace( string input, string pattern, string replacement, RegexOptions options, TimeSpan matchTimeout )

In a specified input string, replaces all strings that match a specified regular expression with a specified replacement string. Additional parameters specify options that modify the matching operation and a time-out interval if no match is found.

  • input The string to search for a match.
  • pattern The regular expression pattern to match.
  • replacement The replacement string.
  • options A bitwise combination of the enumeration values that provide options for matching.
  • matchTimeout A time-out interval, or to indicate that the method should not time out.
  • Returns A new string that is identical to the input string, except that the replacement string takes the place of each matched string. If is not matched in the current instance, the method returns the current instance unchanged.

public static string Replace( string input, string pattern, MatchEvaluator evaluator )

In a specified input string, replaces all strings that match a specified regular expression with a string returned by a delegate.

  • input The string to search for a match.
  • pattern The regular expression pattern to match.
  • evaluator A custom method that examines each match and returns either the original matched string or a replacement string.
  • Returns A new string that is identical to the input string, except that a replacement string takes the place of each matched string. If is not matched in the current instance, the method returns the current instance unchanged.

public static string Replace( string input, string pattern, MatchEvaluator evaluator, RegexOptions options )

In a specified input string, replaces all strings that match a specified regular expression with a string returned by a delegate. Specified options modify the matching operation.

  • input The string to search for a match.
  • pattern The regular expression pattern to match.
  • evaluator A custom method that examines each match and returns either the original matched string or a replacement string.
  • options A bitwise combination of the enumeration values that provide options for matching.
  • Returns A new string that is identical to the input string, except that a replacement string takes the place of each matched string. If is not matched in the current instance, the method returns the current instance unchanged.

public static string Replace( string input, string pattern, MatchEvaluator evaluator, RegexOptions options, TimeSpan matchTimeout )

In a specified input string, replaces all substrings that match a specified regular expression with a string returned by a delegate. Additional parameters specify options that modify the matching operation and a time-out interval if no match is found.

  • input The string to search for a match.
  • pattern The regular expression pattern to match.
  • evaluator A custom method that examines each match and returns either the original matched string or a replacement string.
  • options A bitwise combination of enumeration values that provide options for matching.
  • matchTimeout A time-out interval, or to indicate that the method should not time out.
  • Returns A new string that is identical to the input string, except that the replacement string takes the place of each matched string. If is not matched in the current instance, the method returns the current instance unchanged.

public string Replace( string input, MatchEvaluator evaluator )

In a specified input string, replaces all strings that match a specified regular expression with a string returned by a delegate.

  • input The string to search for a match.
  • evaluator A custom method that examines each match and returns either the original matched string or a replacement string.
  • Returns A new string that is identical to the input string, except that a replacement string takes the place of each matched string. If the regular expression pattern is not matched in the current instance, the method returns the current instance unchanged.

public string Replace( string input, MatchEvaluator evaluator, int count )

In a specified input string, replaces a specified maximum number of strings that match a regular expression pattern with a string returned by a delegate.

  • input The string to search for a match.
  • evaluator A custom method that examines each match and returns either the original matched string or a replacement string.
  • count The maximum number of times the replacement will occur.
  • Returns A new string that is identical to the input string, except that a replacement string takes the place of each matched string. If the regular expression pattern is not matched in the current instance, the method returns the current instance unchanged.

public string Replace( string input, MatchEvaluator evaluator, int count, int startat )

In a specified input substring, replaces a specified maximum number of strings that match a regular expression pattern with a string returned by a delegate.

  • input The string to search for a match.
  • evaluator A custom method that examines each match and returns either the original matched string or a replacement string.
  • count The maximum number of times the replacement will occur.
  • startat The character position in the input string where the search begins.
  • Returns A new string that is identical to the input string, except that a replacement string takes the place of each matched string. If the regular expression pattern is not matched in the current instance, the method returns the current instance unchanged.

public bool RightToLeft { get; }

Gets a value that indicates whether the regular expression searches from right to left.

  • Returns if the regular expression searches from right to left; otherwise, .

public string[] Split( string input )

Splits an input string into an array of substrings at the positions defined by a regular expression pattern specified in the constructor.

  • input The string to split.
  • Returns An array of strings.

public string[] Split( string input, int count )

Splits an input string a specified maximum number of times into an array of substrings, at the positions defined by a regular expression specified in the constructor.

  • input The string to be split.
  • count The maximum number of times the split can occur.
  • Returns An array of strings.

public string[] Split( string input, int count, int startat )

Splits an input string a specified maximum number of times into an array of substrings, at the positions defined by a regular expression specified in the constructor. The search for the regular expression pattern starts at a specified character position in the input string.

  • input The string to be split.
  • count The maximum number of times the split can occur.
  • startat The character position in the input string where the search will begin.
  • Returns An array of strings.

public static string[] Split( string input, string pattern )

Splits an input string into an array of substrings at the positions defined by a regular expression pattern.

  • input The string to split.
  • pattern The regular expression pattern to match.
  • Returns An array of strings.

public static string[] Split( string input, string pattern, RegexOptions options )

Splits an input string into an array of substrings at the positions defined by a specified regular expression pattern. Specified options modify the matching operation.

  • input The string to split.
  • pattern The regular expression pattern to match.
  • options A bitwise combination of the enumeration values that provide options for matching.
  • Returns An array of strings.

public static string[] Split( string input, string pattern, RegexOptions options, TimeSpan matchTimeout )

Splits an input string into an array of substrings at the positions defined by a specified regular expression pattern. Additional parameters specify options that modify the matching operation and a time-out interval if no match is found.

  • input The string to split.
  • pattern The regular expression pattern to match.
  • options A bitwise combination of the enumeration values that provide options for matching.
  • matchTimeout A time-out interval, or to indicate that the method should not time out.
  • Returns A string array.

public static string Unescape( string str )

Converts any escaped characters in the input string.

  • str The input string containing the text to convert.
  • Returns A string of characters with any escaped characters converted to their unescaped form.

public static Regex.ValueMatchEnumerator EnumerateMatches( ReadOnlySpan<char> input, string pattern, RegexOptions options )

😔 No documentation found.

public static void CompileToAssembly( RegexCompilationInfo[] regexinfos, AssemblyName assemblyname, CustomAttributeBuilder[] attributes )

😔 No documentation found.

public static void CompileToAssembly( RegexCompilationInfo[] regexinfos, AssemblyName assemblyname, CustomAttributeBuilder[] attributes, string resourceFile )

😔 No documentation found.

public bool Equals( object obj )

😔 No documentation found.

public static Regex.ValueSplitEnumerator EnumerateSplits( ReadOnlySpan<char> input, string pattern, RegexOptions options )

😔 No documentation found.

public Type GetType( )

😔 No documentation found.

public Regex.ValueSplitEnumerator EnumerateSplits( ReadOnlySpan<char> input, int count, int startat )

😔 No documentation found.

public Regex.ValueSplitEnumerator EnumerateSplits( ReadOnlySpan<char> input, int count )

😔 No documentation found.

public Regex.ValueSplitEnumerator EnumerateSplits( ReadOnlySpan<char> input )

😔 No documentation found.

public static Regex.ValueSplitEnumerator EnumerateSplits( ReadOnlySpan<char> input, string pattern, RegexOptions options, TimeSpan matchTimeout )

😔 No documentation found.

public static Regex.ValueMatchEnumerator EnumerateMatches( ReadOnlySpan<char> input, string pattern, RegexOptions options, TimeSpan matchTimeout )

😔 No documentation found.

public Regex.ValueMatchEnumerator EnumerateMatches( ReadOnlySpan<char> input )

😔 No documentation found.

public Regex.ValueMatchEnumerator EnumerateMatches( ReadOnlySpan<char> input, int startat )

😔 No documentation found.

public int GetHashCode( )

😔 No documentation found.

public static Regex.ValueSplitEnumerator EnumerateSplits( ReadOnlySpan<char> input, string pattern )

😔 No documentation found.

public static void CompileToAssembly( RegexCompilationInfo[] regexinfos, AssemblyName assemblyname )

😔 No documentation found.

public static bool IsMatch( ReadOnlySpan<char> input, string pattern )

😔 No documentation found.

public static int Count( ReadOnlySpan<char> input, string pattern, RegexOptions options )

😔 No documentation found.

public static bool IsMatch( ReadOnlySpan<char> input, string pattern, RegexOptions options )

😔 No documentation found.

public static int Count( ReadOnlySpan<char> input, string pattern )

😔 No documentation found.

public static bool IsMatch( ReadOnlySpan<char> input, string pattern, RegexOptions options, TimeSpan matchTimeout )

😔 No documentation found.

public static int Count( string input, string pattern, RegexOptions options, TimeSpan matchTimeout )

😔 No documentation found.

public static int Count( string input, string pattern, RegexOptions options )

😔 No documentation found.

public bool IsMatch( ReadOnlySpan<char> input )

😔 No documentation found.

public bool IsMatch( ReadOnlySpan<char> input, int startat )

😔 No documentation found.

public static int Count( string input, string pattern )

😔 No documentation found.

public int Count( ReadOnlySpan<char> input, int startat )

😔 No documentation found.

public int Count( ReadOnlySpan<char> input )

😔 No documentation found.

public int Count( string input )

😔 No documentation found.

public int[] GetGroupNumbers( )

😔 No documentation found.

public string[] GetGroupNames( )

😔 No documentation found.

public string ToString( )

😔 No documentation found.

public static Regex.ValueMatchEnumerator EnumerateMatches( ReadOnlySpan<char> input, string pattern )

😔 No documentation found.

public static int Count( ReadOnlySpan<char> input, string pattern, RegexOptions options, TimeSpan matchTimeout )

😔 No documentation found.