[Serializable] |
ctor #2 | Overloaded:.ctor(string pattern) Initializes and compiles an instance of the Regex class for the specified regular expression. |
ctor #3 | Overloaded:.ctor(string pattern, RegexOptions options) Initializes and compiles an instance of the Regex class for the specified regular expression, with options that modify the pattern. |
Options | Read-only Returns the options passed into the Regex constructor. |
RightToLeft | Read-only Gets a value indicating whether the regular expression searches from right to left. |
CompileToAssembly | Overloaded:CompileToAssembly(RegexCompilationInfo[] regexinfos, AssemblyName assemblyname) Compiles one or more specified Regex objects to a named file. |
CompileToAssembly | Overloaded:CompileToAssembly(RegexCompilationInfo[] regexinfos, AssemblyName assemblyname, CustomAttributeBuilder[] attributes) Compiles one or more specified Regex objects to a named file with specified attributes. |
CompileToAssembly | Overloaded:CompileToAssembly(RegexCompilationInfo[] regexinfos, AssemblyName assemblyname, CustomAttributeBuilder[] attributes, string resourceFile) Compiles one or more specified Regex objects and a specified resource file to a named assembly with specified attributes. |
Equals (inherited from System.Object) |
See base class member description: System.Object.Equals Derived from System.Object, the primary base class for all objects. |
Escape | Escapes a minimal set of metacharacters (\, *, +, ?, |, {, [, (, ), ^, $, ., #, and white space) by replacing them with their escape codes. |
GetGroupNames | Returns an array of capturing group names for the regular expression. |
GetGroupNumbers | Returns an array of capturing group numbers that correspond to group names in an array. |
GetHashCode (inherited from System.Object) |
See base class member description: System.Object.GetHashCode Derived from System.Object, the primary base class for all objects. |
GetType (inherited from System.Object) |
See base class member description: System.Object.GetType Derived from System.Object, the primary base class for all objects. |
GroupNameFromNumber | Gets the group name that corresponds to the specified group number. |
GroupNumberFromName | Returns the group number that corresponds to the specified group name. |
IsMatch | Overloaded:IsMatch(string input) Indicates whether the regular expression specified in the Regex constructor finds a match in the input string. |
IsMatch | Overloaded:IsMatch(string input, int startat) Indicates whether the regular expression specified in the Regex constructor finds a match in the input string beginning at the specified starting position in the string. |
IsMatch | Overloaded:IsMatch(string input, string pattern) Indicates whether the regular expression finds a match in the input string using the regular expression specified in the pattern parameter. |
IsMatch | Overloaded:IsMatch(string input, string pattern, RegexOptions options) Indicates whether the regular expression finds a match in the input string, using the regular expression specified in the pattern parameter and the matching options supplied in the options parameter. |
Match | Overloaded:Match Match(string input) Searches the specified input string for an occurrence of the regular expression specified in the Regex constructor. |
Match | Overloaded:Match Match(string input, int startat) Searches the input string for an occurrence of a regular expression with a specified input string starting position. |
Match | Overloaded:Match Match(string input, string pattern) Searches the specified input string for an occurrence of the regular expression supplied in the pattern parameter. |
Match | Overloaded:Match Match(string input, int beginning, int length) Searches the input string for an occurrence of a regular expression with a specified input string starting position and input string length. |
Match | Overloaded:Match Match(string input, string pattern, RegexOptions options) Searches the input string for an occurrence of the regular expression supplied in a pattern parameter with matching options supplied in an options parameter. |
Matches | Overloaded:Matches(string input) Searches the specified input string for all occurrences of a regular expression. |
Matches | Overloaded: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. |
Matches | Overloaded:Matches(string input, string pattern) Searches the specified input string for all occurrences of the regular expression specified in the pattern parameter. |
Matches | Overloaded:Matches(string input, string pattern, RegexOptions options) Searches the specified input string for all occurrences of the regular expression supplied in a pattern parameter with matching options supplied in an options parameter. |
Replace | Overloaded:Replace(string input, MatchEvaluator evaluator) Replaces all occurrences of a character pattern defined by the regular expression specified in the Regex constructor . A MatchEvaluator delegate is called at each match to evaluate the replacement. |
Replace | Overloaded:Replace(string input, string replacement) Replaces all occurrences of a specified regular expression pattern with a replacement string, starting at the first character in the input string. |
Replace | Overloaded:Replace(string input, MatchEvaluator evaluator, int count) Replaces up to a specified number of occurrences of a pattern defined by the regular expression specified in the Regex constructor with a replacement string, starting at the first character in the input string. A MatchEvaluator delegate is called at each match to evaluate the replacement. |
Replace | Overloaded:Replace(string input, string replacement, int count) Replaces up to a specified number of occurrences of a pattern defined by the regular expression specified in the Regex constructor with a specified replacement string, starting at the first character in the input string. |
Replace | Overloaded:Replace(string input, string pattern, MatchEvaluator evaluator) Replaces all occurrences of a character pattern defined by a regular expression with a replacement character string starting at the first character . A MatchEvaluator delegate is called at each match to evaluate the replacement. |
Replace | Overloaded:Replace(string input, string pattern, string replacement) Replaces all occurrences of matches defined by the regular expression with a replacement string, starting at the first character in the input string. |
Replace | Overloaded:Replace(string input, MatchEvaluator evaluator, int count, int startat) Replaces up to a specified number of occurrences of a pattern specified in the Regex constructor with a replacement string, starting at a specified character position in the input string. A MatchEvaluator delegate is called at each match to evaluate the replacement. |
Replace | Overloaded:Replace(string input, string replacement, int count, int startat) Replaces up to a specified number of occurrences of a pattern in the input string defined by the regular expression specified in the Regex constructor with a specified replacement string, starting at a specified character position in the input string. |
Replace | Overloaded:Replace(string input, string pattern, MatchEvaluator evaluator, RegexOptions options) Replaces all occurrences of a character pattern defined by a specified regular expression with a replacement character string starting at the first character . Options can be specified to modify matching behavior and a MatchEvaluator delegate is called at each match to evaluate the replacement. |
Replace | Overloaded:Replace(string input, string pattern, string replacement, RegexOptions options) Replaces all occurrences of a pattern defined by a specified regular expression with a specified replacement character string, starting at the first character in the input string. Options can be specified to modify matching behavior. |
Split | Overloaded:Split(string input) Splits the specified input string at the positions defined by a regular expression pattern specified in the Regex constructor.. |
Split | Overloaded:Split(string input, int count) Splits the specified input string a specified maximum number of times at the positions defined by a regular expression specified in the Regex constructor. |
Split | Overloaded:Split(string input, string pattern) Splits the input string at the positions defined by a regular expression pattern. |
Split | Overloaded:Split(string input, int count, int startat) Splits the specified input string a specified maximum number of times at the positions defined by a regular expression specified in the Regex constructor, starting at a specified character position in the input string |
Split | Overloaded:Split(string input, string pattern, RegexOptions options) Splits the input string at the positions defined by a specified regular expression pattern. Options can be specified to modify matching behavior. |
ToString | Overridden: Returns the regular expression pattern that was passed into the Regex constructor. |
Unescape | Unescapes any escaped characters in the input string. |
ctor #1 | Overloaded:.ctor() Default constructor. This constructor is called by derived class constructors to initialize state in this type.Initializes a new instance of the Regex class with no parameters. |
Finalize | Overridden: Forces a Regex object to free resources before the object is destroyed by the Garbage Collector. |
InitializeReferences | |
MemberwiseClone (inherited from System.Object) |
See base class member description: System.Object.MemberwiseClone Derived from System.Object, the primary base class for all objects. |
UseOptionC | |
UseOptionR |
Hierarchy:
protected Regex(); |
public Regex( |
pattern
Exception Type | Condition |
---|---|
ArgumentException | Regular expression parsing error |
public Regex(string pattern, Regex( |
pattern
options
Exception Type | Condition |
---|---|
ArgumentException | Regular expression parsing error. |
public RegexOptions Options {get;}
|
public bool RightToLeft {get;}
|
public static void CompileToAssembly( |
regexinfos
assemblyname
Exception Type | Condition |
---|---|
ArgumentNullException | assemblyname or regexinfos is null. |
public static void CompileToAssembly( |
regexinfos
assemblyname
attributes
Exception Type | Condition |
---|---|
ArgumentNullException | assemblyname or regexinfos is null. |
public static void CompileToAssembly( |
regexinfos
assemblyname
attributes
resourceFile
Exception Type | Condition |
---|---|
ArgumentNullException | assemblyname or regexinfos is null. |
str
~Regex(); |
public string[] GetGroupNames(); |
public int[] GetGroupNumbers(); |
public virtual int GetHashCode(); |
public Type GetType(); |
i
name
protected void InitializeReferences(); |
Exception Type | Condition |
---|---|
NotSupportedException | References have already been initialized. |
input
input
startat
input
pattern
public static bool IsMatch( |
input
pattern
options
input
input
startat
If you want to restrict a match so it does not scan, anchor the regular expression with a \G (at the left for a left-to-right pattern, or at the right for a right-to-left pattern). This restricts the match so it must start exactly at startpos.
When a Regex is left-to-right (the default), the match and the scan proceed rightward, starting at the character specified in startat. When a Regex is right-to-left (when it is constructed with the RegexOptions.RightToLeft option), the match and scan proceed in the opposite direction and begin with the character at startat -1.
input
pattern
input
beginning
length
public static Match Match( |
input
pattern
options
When a Regex is left-to-right (the default), the match and the scan proceed rightward, starting at the character at startat. When a Regex is right-to-left (constructed with the RegexOptions.RightToLeft option enabled), the match and scan are in the opposite direction and begin with the character at startat -1.
The static Match methods are equivalent to constructing a Regex object with the specified pattern and calling the instance method Match. The static methods are provided to allow an isolated, single use of a regular expression without explicitly creating a Regex object.
public MatchCollection Matches( |
input
public MatchCollection Matches( |
input
startat
public static MatchCollection Matches( |
input
pattern
The static Matches methods are equivalent to constructing a Regex object with the specified regular expression pattern and calling the instance method Matches. The static methods are provided to allow an isolated, single use of a regular expression without explicitly creating a Regex object.
public static MatchCollection Matches( |
input
pattern
options
The static Matches methods are equivalent to constructing a Regex object with the specified regular expression pattern and calling the instance method Matches. The static methods are provided to allow an isolated, single use of a regular expression without explicitly creating a Regex object.
protected object MemberwiseClone(); |
public string Replace( |
input
evaluator
public delegate String RegexMatchEvaluator(Match match);
The delegate is called once per match during a replace.input
replacement
public string Replace( |
input
evaluator
count
public delegate String RegexMatchEvaluator(Match match);
The delegate is called once per match during a replace.input
replacement
count
public static string Replace( |
input
pattern
evaluator
public delegate String RegexMatchEvaluator(Match match);
The delegate is called once per match during a replace.
input
pattern
replacement
Character escapes and substitutions are the only special constructs recognized in a replacement pattern. All other syntactic constructs are allowed in regular expressions only and not recognized in replacement patterns. For example, the replacement pattern a*${test}b inserts the string "a*" followed by the substring matched by the "test" capturing group, if any, followed by the string "b". The * character is not recognized as a metacharacter within a replacement pattern. Similarly, $-patterns are not recognized within a regular expression matching pattern. Within a regular expression, $ denotes the end of the string. Other examples are: $123 substitutes the last substring matched by group number 123 (decimal), and ${name) substitutes the last substring matched by a (?<name>) group.
The static Replace methods are equivalent to constructing a Regex object with the specified regular expression pattern and calling the instance method Replace. The static methods are provided to allow an isolated, single use of a regular expression without explicitly creating a Regex object.
public string Replace( |
input
evaluator
count
startat
public delegate String RegexMatchEvaluator(Match match);
The delegate is called once per match during a replace.input
replacement
count
startat
public static string Replace( |
input
pattern
evaluator
options
public delegate String RegexMatchEvaluator(Match match);
The delegate is called once per match during a replace.
public static string Replace( |
input
pattern
replacement
options
input
If capturing groups are used in a Regex.Split expression, the capturing groups are included in the resulting string array. The following example would yield the array items "one", "-", "two", "-", "banana".
Regex r = new Regex("(-)"); // Split on hyphens. string[] s = r.Split("one-two-banana");
If the regular expression can match the empty string (for example, x*), Split will split the string into an array of single-character strings because the empty string delimiter can be found at every location.
The static Split methods are equivalent to constructing a Regex object with the specified regular expression pattern and calling the instance method Split. The static methods are provided to allow an isolated, single use of a regular expression without explicitly creating a Regex object.input
count
Also, if capturing groups are used in a split expression, these are included in the array of split strings. For example:
Regex r = new Regex("(-)"); // Split on hyphens. string[] s = r.Split("one-two-banana");
would yield the following array items:"one", "-", "two", "-", "banana"
If the regular expression can match the empty string (for example, x*), Split will split the string into an array of single-character strings because the empty string delimiter can be found at every location.
The static Split methods are equivalent to constructing a Regex object with the specified regular expression pattern and calling the instance method Split. The static methods are provided to allow an isolated, single use of a regular expression without explicitly creating a Regex object.input
pattern
If capturing groups are used in a Regex.Split expression, the capturing groups are included in the resulting string array. The following example would yield the array items "one", "-", "two", "-", "banana".
Regex r = new Regex("(-)"); // Split on hyphens. string[] s = r.Split("one-two-banana");
If the regular expression can match the empty string (for example, x*), Split will split the string into an array of single-character strings because the empty string delimiter can be found at every location.
The static Split methods are equivalent to constructing a Regex object with the specified regular expression pattern and calling the instance method Split. The static methods are provided to allow an isolated, single use of a regular expression without explicitly creating a Regex object.
input
count
startat
Also, if capturing groups are used in a split expression, these are included in the array of split strings. For example:
Regex r = new Regex("(-)"); // Split on hyphens. string[] s = r.Split("one-two-banana");
would yield the following array items:"one", "-", "two", "-", "banana"
If the regular expression can match the empty string (for example, x*), Split will split the string into an array of single-character strings because the empty string delimiter can be found at every location.
The static Split methods are equivalent to constructing a Regex object with the specified regular expression pattern and calling the instance method Split. The static methods are provided to allow an isolated, single use of a regular expression without explicitly creating a Regex object.
public static string[] Split( |
input
pattern
options
If capturing groups are used in a Regex.Split expression, the capturing groups are included in the resulting string array. The following example would yield the array items "one", "-", "two", "-", "banana".
Regex r = new Regex("(-)"); // Split on hyphens. string[] s = r.Split("one-two-banana");
If the regular expression can match the empty string (for example, x*), Split will split the string into an array of single-character strings because the empty string delimiter can be found at every location.
The static Split methods are equivalent to constructing a Regex object with the specified regular expression pattern and calling the instance method Split. The static methods are provided to allow an isolated, single use of a regular expression without explicitly creating a Regex object.
public override string ToString(); |
str
protected bool UseOptionC(); |
protected bool UseOptionR(); |