System
[00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00]
1.0.3300.0
1.0.5000.0
2.0.0.0
4.0.0.0
Gtk# is thread aware, but not thread safe; See the <link location="node:gtk-sharp/programming/threads">Gtk# Thread Programming</link> for details.
System.Object
System.Runtime.Serialization.ISerializable
The class represents the .NET Framework's regular expression engine. It can be used to quickly parse large amounts of text to find specific character patterns; to extract, edit, replace, or delete text substrings; and to add the extracted strings to a collection to generate a report.
If your primary interest is to validate a string by determining whether it conforms to a particular pattern, you can use the class.
To use regular expressions, you define the pattern that you want to identify in a text stream by using the syntax documented in Regular Expression Language Elements. Next, you can optionally instantiate a object. Finally, you call a method that performs some operation, such as replacing text that matches the regular expression pattern, or identifying a pattern match.
For more information about using the class, see the following sections:
-
Regex vs. String Methods
-
Static vs. Instance Methods
-
Performing Regular Expression Operations
-
Defining a Time-Out Value
Regex vs. String Methods
The class includes several search and comparison methods that you can use to perform pattern matching with text. For example, the , , and methods determine whether a string instance contains a specified substring; and the , , , and methods return the starting position of a specified substring in a string. Use the methods of the class when you are searching for a specific string. Use the class when you are searching for a specific pattern in a string. For more information and examples, see .NET Framework Regular Expressions.
Back to Remarks
Static vs. Instance Methods
After you define a regular expression pattern, you can provide it to the regular expression engine in either of two ways:
-
By instantiating a object that represents the regular expression. To do this, you pass the regular expression pattern to a constructor. A object is immutable; when you instantiate a object with a regular expression, that object's regular expression cannot be changed.
-
By supplying both the regular expression and the text to search to a static (Shared in Visual Basic) method. This enables you to use a regular expression without explicitly creating a object.
All pattern identification methods include both static and instance overloads.
The regular expression engine must compile a particular pattern before the pattern can be used. Because objects are immutable, this is a one-time procedure that occurs when a class constructor or a static method is called. To eliminate the need to repeatedly compile a single regular expression, the regular expression engine caches the compiled regular expressions used in static method calls. As a result, regular expression pattern-matching methods offer comparable performance for static and instance methods.
In the .NET Framework versions 1.0 and 1.1, all compiled regular expressions, whether they were used in instance or static method calls, were cached. Starting with the .NET Framework 2.0, only regular expressions used in static method calls are cached.
However, caching can adversely affect performance in the following two cases:
-
When you use static method calls with a large number of regular expressions. By default, the regular expression engine caches the 15 most recently used static regular expressions. If your application uses more than 15 static regular expressions, some regular expressions must be recompiled. To prevent this recompilation, you can increase the property.
-
When you instantiate new objects with regular expressions that have previously been compiled. For example, the following code defines a regular expression to locate duplicated words in a text stream. Although the example uses a single regular expression, it instantiates a new object to process each line of text. This results in the recompilation of the regular expression with each iteration of the loop.
code reference: System.Text.RegularExpressions.Class.Caching#1
To prevent recompilation, you should instantiate a single object that is accessible to all code that requires it, as shown in the following rewritten example.
code reference: System.Text.RegularExpressions.Class.Caching#2
Back to Remarks
Performing Regular Expression Operations
Whether you decide to instantiate a object and call its methods or call static methods, the class offers the following pattern-matching functionality:
-
Validation of a match. You call the method to determine whether a match is present.
-
Retrieval of a single match. You call the method to retrieve a object that represents the first match in a string or in part of a string. Subsequent matches can be retrieved by calling the method.
-
Retrieval of all matches. You call the method to retrieve a object that represents all the matches found in a string or in part of a string.
-
Replacement of matched text. You call the method to replace matched text. The replacement text can also be defined by a regular expression. In addition, some of the methods include a parameter that enables you to programmatically define the replacement text.
-
Creation of a string array that is formed from parts of an input string. You call the method to split an input string at positions that are defined by the regular expression.
In addition to its pattern-matching methods, the class includes several special-purpose methods:
-
The method escapes any characters that may be interpreted as regular expression operators in a regular expression or input string.
-
The method removes these escape characters.
-
The method creates an assembly that contains predefined regular expressions. The .NET Framework contains examples of these special-purpose assemblies in the namespace.
Back to Remarks
Defining a Time-Out Value
The .NET Framework supports a full-featured regular expression language that provides substantial power and flexibility in pattern matching. However, the power and flexibility come at a cost: the risk of poor performance. Regular expressions that perform poorly are surprisingly easy to create. In some cases, regular expression operations that rely on excessive backtracking can appear to stop responding when they process text that nearly matches the regular expression pattern. For more information about the .NET Framework regular expression engine, see Details of Regular Expression Behavior. For more information about excessive backtracking, see Backtracking.
Starting with the net_v45, you can define a time-out interval for regular expression matches. If the regular expression engine cannot identify a match within this time interval, the matching operation throws a exception. In most cases, this prevents the regular expression engine from wasting processing power by trying to match text that nearly matches the regular expression pattern. It also could indicate, however, that the timeout interval has been set too low, or that the current machine load has caused an overall degradation in performance.
How you handle the exception depends on the cause of the exception. If the exception occurs because the time-out interval is set too low or because of excessive machine load, you can increase the time-out interval and retry the matching operation. If the exception occurs because the regular expression relies on excessive backtracking, you can assume that a match does not exist, and, optionally, you can log information that will help you modify the regular expression pattern.
You can set a time-out interval by calling the constructor when you instantiate a regular expression object. For static methods, you can set a time-out interval by calling an overload of a matching method that has a parameter. If you do not set a time-out value explicitly, the default time-out value is determined as follows:
-
By using the application-wide time-out value, if one exists. This can be any time-out value that applies to the application domain in which the object is instantiated or the static method call is made. You can set the application-wide time-out value by calling the method to assign the string representation of a value to the "REGEX_DEFAULT_MATCH_TIMEOUT" property.
-
By using the value , if no application-wide time-out value has been set.
We recommend that you set a time-out value in all regular expression pattern-matching operations. For more information, see Best Practices for Regular Expressions in the .NET Framework.
Back to Remarks
Represents an immutable regular expression.
Constructor
1.0.5000.0
2.0.0.0
4.0.0.0
To be added
Initializes a new instance of the class.
Constructor
1.0.5000.0
2.0.0.0
4.0.0.0
The parameter consists of regular expression language elements that symbolically describe the string to match. For more information about regular expressions, see the .NET Framework Regular Expressions and Regular Expression Language Elements topics.
Calling the constructor is equivalent to calling the constructor with a value of for the argument.
A object is immutable, which means that it can be used only for the match pattern you define when you create it. However, it can be used any number of times without being recompiled.
This constructor instantiates a regular expression object that attempts a case-sensitive match of any alphabetical characters defined in . For a case-insensitive match, use the constructor.
Initializes a new instance of the class for the specified regular expression.
The regular expression pattern to match.
Constructor
2.0.0.0
4.0.0.0
To be added.
Initializes a new instance of the class by using serialized data.
The object that contains a serialized pattern and information.
The destination for this serialization. (This parameter is not used; specify null.)
Constructor
1.0.5000.0
2.0.0.0
4.0.0.0
The parameter consists of regular expression language elements that symbolically describe the string to match. For more information about regular expressions, see the .NET Framework Regular Expressions and Regular Expression Language Elements topics.
A object is immutable, which means that it can be used only for the match parameters you define when you create it. However, it can be used any number of times without being recompiled.
Initializes a new instance of the class for the specified regular expression, with options that modify the pattern.
The regular expression pattern to match.
A bitwise combination of the enumeration values that modify the regular expression.
Constructor
4.0.0.0
System.MonoTODO("Timeouts are ignored.")
The parameter consists of regular expression language elements that symbolically describe the string to match. For more information about regular expressions, see the .NET Framework Regular Expressions and Regular Expression Language Elements topics.
A object is immutable, which means that it can be used only for the match pattern that you define when you create it. However, it can be used any number of times without being recompiled.
The parameter specifies how long a pattern-matching method should try to find a match before it times out. If no match is found in that time interval, the pattern-matching method throws a exception. overrides any default time-out value defined for the application domain in which the object is created. The instance pattern-matching methods that observe the time-out interval include the following:
-
-
-
-
-
-
Setting a time-out interval prevents regular expressions that rely on excessive backtracking from appearing to stop responding when they process input that contains near matches. For more information, see Best Practices for Regular Expressions in the .NET Framework and Backtracking. To set a reasonable time-out interval, consider the following factors:
-
The length and complexity of the regular expression pattern. Longer and more complex regular expressions require more time than shorter and simpler ones.
-
The expected machine load. Processing takes more time on systems that have high CPU and memory utilization.
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.
The regular expression pattern to match.
A bitwise combination of the enumeration values that modify the regular expression.
A time-out interval, or to indicate that the method should not time out.
Property
2.0.0.0
4.0.0.0
System.Int32
To be added.
The class maintains an internal cache of compiled regular expressions used in static method calls. If the value specified in a set operation is less than the current cache size, cache entries are discarded until the cache size is equal to the specified value.
By default, the cache holds 15 compiled static regular expressions. Your application typically will not have to modify the size of the cache. Use the property only when you want to turn off caching or when you have an unusually large cache.
Gets or sets the maximum number of entries in the current static cache of compiled regular expressions.
Field
1.0.5000.0
2.0.0.0
4.0.0.0
System.MonoTODO
System.Collections.Hashtable
To be added.
Used by a object generated by the method.
Field
1.0.5000.0
2.0.0.0
4.0.0.0
System.MonoTODO
System.Collections.Hashtable
To be added.
Used by a object generated by the method.
Field
1.0.5000.0
2.0.0.0
4.0.0.0
System.MonoTODO
System.Int32
To be added.
Used by a object generated by the method.
Field
1.0.5000.0
2.0.0.0
4.0.0.0
System.MonoTODO
System.String[]
To be added.
Used by a object generated by the method.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.MonoTODO
System.Void
To be added.
To be added.
The method generates a .NET Framework assembly in which each regular expression defined in the array is represented by a class. Typically, the method is called from a separate application that generates an assembly of compiled regular expressions. Each regular expression included in the assembly has the following characteristics:
-
It is derived from the class.
-
It is assigned the fully qualified name that is defined by the and parameters of its corresponding object.
-
It has a default (or parameterless) constructor.
Ordinarily, the code that instantiates and uses the compiled regular expression is found in an assembly or application that is separate from the code that creates the assembly.
Compiles one or more specified objects to a named assembly.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.MonoTODO
System.Void
To be added.
To be added.
To be added.
The method generates a .NET Framework assembly in which each regular expression defined in the array is represented by a class. Typically, the method is called from a separate application that generates an assembly of compiled regular expressions. Each regular expression included in the assembly has the following characteristics:
-
It is derived from the class.
-
It is assigned the fully qualified name that is defined by the and parameters of its corresponding object.
-
It has a default (or parameterless) constructor.
Ordinarily, the code that instantiates and uses the compiled regular expression is found in an assembly or application that is separate from the code that creates the assembly.
Because the method generates a .NET Framework assembly from a method call instead of using a particular language's class definition keyword (such as class in C# or Class…End Class in Visual Basic), it does not allow .NET Framework attributes to be assigned to the assembly by using the development language's standard attribute syntax. The parameter provides an alternative method for defining the attributes that apply to the assembly. For each attribute that you want to apply to the assembly, do the following:
-
Create an array of objects representing the parameter types of the attribute constructor that you want to call.
-
Retrieve a object representing the attribute class that you want to apply to the new assembly.
-
Call the method of the attribute object to retrieve a object representing the attribute constructor that you want to call. Pass the method the array of objects that represents the constructor's parameter types.
-
Create a array that defines the parameters to pass to the attribute's constructor.
-
Instantiate a object by passing its constructor the object retrieved in step 3 and the array created in step 4.
You can then pass an array of these objects instead of the parameter to the method.
Compiles one or more specified objects to a named assembly with the specified attributes.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.MonoTODO
System.Void
To be added.
To be added.
To be added.
The method generates a .NET Framework assembly in which each regular expression defined in the array is represented by a class. Typically, the method is called from a separate application that generates an assembly of compiled regular expressions. Each regular expression included in the assembly has the following characteristics:
-
It is derived from the class.
-
It is assigned the fully qualified name that is defined by the and parameters of its corresponding object.
-
It has a default (or parameterless) constructor.
Ordinarily, the code that instantiates and uses the compiled regular expression is found in an assembly or application that is separate from the code that creates the assembly.
Because the method generates a .NET Framework assembly from a method call instead of using a particular language's class definition keyword (such as class in C# or Class…End Class in Visual Basic), it does not allow .NET Framework attributes to be assigned to the assembly by using the development language's standard attribute syntax. The parameter provides an alternative method for defining the attributes that apply to the assembly. For each attribute that you want to apply to the assembly, do the following:
-
Create an array of objects representing the parameter types of the attribute constructor that you want to call.
-
Retrieve a object representing the attribute class that you want to apply to the new assembly.
-
Call the method of the attribute object to retrieve a object representing the attribute constructor that you want to call. Pass the method the array of objects that represents the constructor's parameter types
-
Create a array that defines the parameters to pass to the attribute's constructor.
-
Instantiate a object by passing its constructor the object retrieved in step 3 and the array created in step 4.
You can then pass an array of these objects instead of the parameter to the method.
Compiles one or more specified objects and a specified resource file to a named assembly with the specified attributes.
The name of the Win32 resource file to include in the assembly.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.String
converts a string so that the regular expression engine will interpret any metacharacters that it may contain as character literals. For example, consider a regular expression that is designed to extract comments that are delimited by straight opening and closing brackets ([ and ]) from text. In the following example, the regular expression "[(.*?)]" is interpreted as a character class. Rather than matching comments embedded in the input text, the regular expression matches each opening or closing parenthesis, period, asterisk, or question mark.
code reference: System.Text.RegularExpressions.Regex.Escape#1
However, if the opening bracket is escaped by passing it to the method, the regular expression succeeds in matching comments that are embedded in the input string. The following example illustrates this.
code reference: System.Text.RegularExpressions.Regex.Escape#2
In a regular expression that is defined by using static text, characters that are to be interpreted literally rather than as metacharacters can be escaped by preceding them with a backslash symbol (\) as well as by calling the method. In a regular expression that is defined dynamically using characters that are not known at design time, calling the method is particularly important to ensure that the regular expression engine interprets individual characters as literals rather than as metacharacters.
If a regular expression pattern includes either the number sign (#) or literal white-space characters, they must be escaped if input text is parsed with the option enabled.
While the method escapes the straight opening bracket ([) and opening brace ({) characters, it does not escape their corresponding closing characters (] and }). In most cases, escaping these is not necessary. If a closing bracket or brace is not preceded by its corresponding opening character, the regular expression engine interprets it literally. If an opening braket or brace is interpreted as a metacharacter, the regular expression engine interprets the first corresponding closing character as a metacharacter. If this is not the desired behavior, the closing bracket or brace should be escaped by explicitly prepending the backslash (\) character. For an illustration, see the Example section.
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.
A string of characters with metacharacters converted to their escaped form.
The input string that contains the text to convert.
Field
1.0.5000.0
2.0.0.0
4.0.0.0
System.MonoTODO
System.Text.RegularExpressions.RegexRunnerFactory
To be added.
Used by a object generated by the method.
Method
1.0.5000.0
System.Void
To be added.
To be added.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.String[]
The collection of group names contains the set of strings used to name capturing groups in the expression. Even if capturing groups are not explicitly named, they are automatically assigned numerical names (1, 2, 3, and so on). Therefore, this collection can be used to determine the number of groups.
Returns an array of capturing group names for the regular expression.
A string array of group names.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Int32[]
Both unnamed and named capturing groups can be accessed by number. Unnamed groups are numbered from left to right starting with 1. (The capturing group in index 0 (zero) represents the match as a whole.) Named groups are then numbered from left to right starting with a number that is one greater than the number of unnamed capturing groups.
Referencing a group by its number instead of by string name can provide faster access.
Returns an array of capturing group numbers that correspond to group names in an array.
An integer array of group numbers.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.String
A regular expression pattern may contain either named or numbered capturing groups, which delineate subexpressions within a pattern match. Numbered groups are delimited by the syntax (subexpression) and are assigned numbers based on their order in the regular expression. Named groups are delimited by the syntax (?<name>subexpression) or (?'name'subexpression), where name is the name by which the subexpression will be identified. (For more information, see Grouping Constructs.) The method identifies both named groups and numbered groups by their ordinal positions in the regular expression. Ordinal position zero always represents the entire regular expression. All numbered groups are then counted before named groups, regardless of their actual position in the regular expression pattern.
If is the number of a named group, the method returns the name of the group. If is the number of an unnamed group, the method returns the string representation of the number. For example, if is 1, the method returns "1". If is not the number of a capturing group, the method returns .
If a pattern match is found, the value returned by this method can then be used to retrieve the object that represents the captured group from the property. The object is returned by the property.
Gets the group name that corresponds to the specified group number.
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 .
The group number to convert to the corresponding group name.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Int32
A regular expression pattern may contain either named or numbered capturing groups, which delineate subexpressions within a pattern match. Numbered groups are delimited by the syntax (subexpression) and are assigned numbers based on their order in the regular expression. Named groups are delimited by the syntax (?<name>subexpression) or (?'name'subexpression), where name is the name by which the subexpression will be identified. (For more information, see Grouping Constructs.) The method identifies both named groups and numbered groups by their ordinal positions in the regular expression. Ordinal position zero always represents the entire regular expression. All numbered groups are then counted before named groups, regardless of their actual position in the regular expression pattern.
If is the string representation of a group number that is present in the regular expression pattern, the method returns that number. If corresponds to a named capturing group that is present in the regular expression pattern, the method returns its corresponding number. The comparison of with the group name is case-sensitive. If does not correspond to the name of a capturing group or to the string representation of the number of a capturing group, the method returns -1.
Returns the group number that corresponds to the specified group name.
The group number that corresponds to the specified group name, or -1 if is not a valid group name.
The group name to convert to the corresponding group number.
Field
4.0.0.0
System.TimeSpan
The class constructor and a number of static matching methods use the constant to indicate that the attempt to find a pattern match should not time out.
Setting the regular expression engine's time-out value to can cause regular expressions that rely on excessive backtracking to appear to stop responding when processing text that nearly matches the regular expression pattern. If you disable time-outs, you should ensure that your regular expression does not rely on excessive backtracking and that it handles text that nearly matches the regular expression pattern.
For more information about handling backtracking, see Backtracking.
The constant can be supplied as the value of the argument of the following members:
-
-
-
-
-
-
-
-
Specifies that a pattern-matching operation should not time out.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Void
To be added
Used by a object generated by the method.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Boolean
The method is typically used to validate a string or to ensure that a string conforms to a particular pattern without retrieving that string for subsequent manipulation. If you want to determine whether one or more strings match a regular expression pattern and then retrieve them for subsequent manipulation, call the or method.
The exception is thrown if the execution time of the matching operation exceeds the time-out interval specified by the constructor. If you do not set a time-out interval when you call the constructor, the exception is thrown if the operation exceeds any time-out value established for the application domain in which the object is created. If no time-out is defined in the constructor call or in the application domain's properties, or if the time-out value is , no exception is thrown.
Indicates whether the regular expression specified in the constructor finds a match in a specified input string.
true if the regular expression finds a match; otherwise, false.
The string to search for a match.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Boolean
The method is typically used to validate a string or to ensure that a string conforms to a particular pattern without retrieving that string for subsequent manipulation. If you want to determine whether one or more strings match a regular expression pattern and then retrieve them for subsequent manipulation, call the or method.
The exception is thrown if the execution time of the matching operation exceeds the time-out interval specified by the constructor. If you do not set a time-out interval when you call the constructor, the exception is thrown if the operation exceeds any time-out value established for the application domain in which the object is created. If no time-out is defined in the constructor call or in the application domain's properties, or if the time-out value is , no exception is thrown.
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.
true if the regular expression finds a match; otherwise, false.
The string to search for a match.
The character position at which to start the search.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Boolean
The method is typically used to validate a string or to ensure that a string conforms to a particular pattern without retrieving that string for subsequent manipulation. If you want to determine whether one or more strings match a regular expression pattern and then retrieve them for subsequent manipulation, call the or method.
The static method is equivalent to constructing a object with the regular expression pattern specified by and calling the instance method. This regular expression pattern is cached for rapid retrieval by the regular expression engine.
The parameter consists of regular expression language elements that symbolically describe the string to match. For more information about regular expressions, see .NET Framework Regular Expressions and Regular Expression Language Elements.
The exception is thrown if the execution time of the matching operation exceeds the time-out interval specified for the application domain in which the method is called. If no time-out is defined in the application domain's properties, or if the time-out value is , no exception is thrown.
Indicates whether the specified regular expression finds a match in the specified input string.
true if the regular expression finds a match; otherwise, false.
The string to search for a match.
The regular expression pattern to match.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Boolean
The method is typically used to validate a string or to ensure that a string conforms to a particular pattern without retrieving that string for subsequent manipulation. If you want to determine whether one or more strings match a regular expression pattern and then retrieve them for subsequent manipulation, call the or method.
The static method is equivalent to constructing a object with the regular expression pattern specified by and the regular expression options specified by and calling the instance method. This regular expression pattern is cached for rapid retrieval by the regular expression engine.
The parameter consists of regular expression language elements that symbolically describe the string to match. For more information about regular expressions, see .NET Framework Regular Expressions and Regular Expression Language Elements.
The exception is thrown if the execution time of the matching operation exceeds the time-out interval specified for the application domain in which the method is called. If no time-out is defined in the application domain's properties, or if the time-out value is , no exception is thrown.
Indicates whether the specified regular expression finds a match in the specified input string, using the specified matching options.
true if the regular expression finds a match; otherwise, false.
The string to search for a match.
The regular expression pattern to match.
A bitwise combination of the enumeration values that provide options for matching.
Method
4.0.0.0
System.MonoTODO("Timeouts are ignored.")
System.Boolean
The method is typically used to validate a string or to ensure that a string conforms to a particular pattern without retrieving that string for subsequent manipulation. If you want to determine whether one or more strings match a regular expression pattern and then retrieve them for subsequent manipulation, call the or method.
The static method is equivalent to constructing a object with the regular expression pattern specified by and the regular expression options specified by and calling the instance method. This regular expression pattern is cached for rapid retrieval by the regular expression engine.
The parameter consists of regular expression language elements that symbolically describe the string to match. For more information about regular expressions, see .NET Framework Regular Expressions and Regular Expression Language Elements.
The parameter specifies how long a pattern matching method should try to find a match before it times out. Setting a time-out interval prevents regular expressions that rely on excessive backtracking from appearing to stop responding when they process input that contains near matches. For more information, see Best Practices for Regular Expressions in the .NET Framework and Backtracking. If no match is found in that time interval, the method throws a exception. overrides any default time-out value defined for the application domain in which the method executes.
Indicates whether the specified regular expression finds a match in the specified input string, using the specified matching options and time-out interval.
true if the regular expression finds a match; otherwise, false.
The string to search for a match.
The regular expression pattern to match.
A bitwise combination of the enumeration values that provide options for matching.
A time-out interval, or to indicate that the method should not time out.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Text.RegularExpressions.Match
The method returns the first substring that matches a regular expression pattern in an input string. For information about the language elements used to build a regular expression pattern, see Regular Expression Language - Quick Reference.
You can determine whether the regular expression pattern has been found in the input string by checking the value of the returned object's property. If a match is found, the returned object's property contains the substring from that matches the regular expression pattern. If no match is found, its value is .
This method returns the first substring in that matches the regular expression pattern. You can retrieve subsequent matches by repeatedly calling the returned object's method. You can also retrieve all matches in a single method call by calling the method.
The exception is thrown if the execution time of the matching operation exceeds the time-out interval specified by the constructor. If you do not set a time-out interval when you call the constructor, the exception is thrown if the operation exceeds any time-out value established for the application domain in which the object is created. If no time-out is defined in the constructor call or in the application domain's properties, or if the time-out value is , no exception is thrown.
Searches the specified input string for the first occurrence of the regular expression specified in the constructor.
An object that contains information about the match.
The string to search for a match.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Text.RegularExpressions.Match
The method returns the first substring that matches a regular expression pattern, starting at or after the character position, in an input string. For information about the language elements used to build a regular expression pattern, see Regular Expression Language - Quick Reference.
The regular expression pattern for which the method searches is defined by the call to one of the class constructors. For more information about the elements that can form a regular expression pattern, see Regular Expression Language Elements.
You can optionally specify a starting position in the string by using the parameter. When the regular expression engine parses from left to right (the default), the match and the scan move rightward, starting at the character specified in . When the regular expression engine parses from right to left (when the regular expression pattern is constructed with the option), the match and scan move in the opposite direction and begin with the character at -1. If you do not specify a starting position, the search begins at the default position. If the regular expression searches from left to right, the default position is at the left end of ; if it searches from right to left, the default position is at the right end of .
If you want to restrict a match so that it begins at a particular character position in the string and the regular expression engine does not scan the remainder of the string for a match, 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 .
You can determine whether the regular expression pattern has been found in the input string by checking the value of the returned object's property. If a match is found, the returned object's property contains the substring from that matches the regular expression pattern. If no match is found, its value is .
This method returns the first substring found at or after the character position in that matches the regular expression pattern. You can retrieve subsequent matches by repeatedly calling the returned object's method. You can also retrieve all matches in a single method call by calling the method.
The exception is thrown if the execution time of the matching operation exceeds the time-out interval specified by the constructor. If you do not set a time-out interval when you call the constructor, the exception is thrown if the operation exeeds any time-out value established for the application domain in which the object is created. If no time-out is defined in the constructor call or in the application domain's properties, or if the time-out value is , no exception is thrown.
Searches the input string for the first occurrence of a regular expression, beginning at the specified starting position in the string.
An object that contains information about the match.
The string to search for a match.
The zero-based character position at which to start the search.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Text.RegularExpressions.Match
The method returns the first substring that matches a regular expression pattern in an input string. For information about the language elements used to build a regular expression pattern, see Regular Expression Language - Quick Reference.
The static method is equivalent to constructing a object with the specified regular expression pattern and calling the instance method. In this case, the regular expression engine caches the regular expression pattern.
The parameter consists of regular expression language elements that symbolically describe the string to match. For more information about regular expressions, see .NET Framework Regular Expressions and Regular Expression Language Elements.
You can determine whether the regular expression pattern has been found in the input string by checking the value of the returned object's property. If a match is found, the returned object's property contains the substring from that matches the regular expression pattern. If no match is found, its value is .
This method returns the first substring in that matches the regular expression pattern. You can retrieve subsequent matches by repeatedly calling the returned object's method. You can also retrieve all matches in a single method call by calling the method.
The exception is thrown if the execution time of the matching operation exceeds the time-out interval specified for the application domain in which the method is called. If no time-out is defined in the application domain's properties, or if the time-out value is , no exception is thrown.
Searches the specified input string for the first occurrence of the specified regular expression.
An object that contains information about the match.
The string to search for a match.
The regular expression pattern to match.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Text.RegularExpressions.Match
The method returns the first substring that matches a regular expression pattern in a portion of an input string. For information about the language elements used to build a regular expression pattern, see Regular Expression Language - Quick Reference.
The regular expression pattern for which the method searches is defined by the call to one of the class constructors. For more information about the elements that can form a regular expression pattern, see Regular Expression Language Elements.
The method searches the portion of defined by the and parameters for the regular expression pattern. always defines the index of the leftmost character to include in the search, and defines the maximum number of characters to search. Together, they define the range of the search. If the search proceeds from left to right (the default), the regular expression engine searches from the character at index to the character at index + – 1. If the regular expression engine was instantiated by using the option so that the search proceeds from right to left, the regular expression engine searches from the character at index + – 1 to the character at index . This method returns the first match that it finds within this range. You can retrieve subsequent matches by repeatedly calling the returned object's method.
You can determine whether the regular expression pattern has been found in the input string by checking the value of the returned object's property. If a match is found, the returned object's property contains the substring from that matches the regular expression pattern. If no match is found, its value is .
The exception is thrown if the execution time of the matching operation exceeds the time-out interval specified by the constructor. If you do not set a time-out value when you call the constructor, the exception is thrown if the operation exceeds any time-out value established for the application domain in which the object is created. If no time-out is defined in the constructor call or in the application domain's properties, or if the time-out value is , no exception is thrown.
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.
An object that contains information about the match.
The string to search for a match.
The zero-based character position in the input string that defines the leftmost position to be searched.
The number of characters in the substring to include in the search.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Text.RegularExpressions.Match
The method returns the first substring that matches a regular expression pattern in an input string. For information about the language elements used to build a regular expression pattern, see Regular Expression Language - Quick Reference.
The static method is equivalent to constructing a object with the constructor and calling the instance method.
The parameter consists of regular expression language elements that symbolically describe the string to match. For more information about regular expressions, see .NET Framework Regular Expressions and Regular Expression Language Elements.
You can determine whether the regular expression pattern has been found in the input string by checking the value of the returned object's property. If a match is found, the returned object's property contains the substring from that matches the regular expression pattern. If no match is found, its value is .
This method returns the first substring found in that matches the regular expression pattern. You can retrieve subsequent matches by repeatedly calling the returned object's method. You can also retrieve all matches in a single method call by calling the method.
The exception is thrown if the execution time of the matching operation exceeds the time-out interval specified for the application domain in which the method is called. If no time-out is defined in the application domain's properties, or if the time-out value is , no exception is thrown.
Searches the input string for the first occurrence of the specified regular expression, using the specified matching options.
An object that contains information about the match.
The string to search for a match.
The regular expression pattern to match.
A bitwise combination of the enumeration values that provide options for matching.
Method
4.0.0.0
System.MonoTODO("Timeouts are ignored.")
System.Text.RegularExpressions.Match
The method returns the first substring that matches a regular expression pattern in an input string. For information about the language elements used to build a regular expression pattern, see Regular Expression Language - Quick Reference.
The static method is equivalent to constructing a object with the constructor and calling the instance method.
The parameter consists of regular expression language elements that symbolically describe the string to match. For more information about regular expressions, see .NET Framework Regular Expressions and Regular Expression Language Elements.
You can determine whether the regular expression pattern has been found in the input string by checking the value of the returned object's property. If a match is found, the returned object's property contains the substring from that matches the regular expression pattern. If no match is found, its value is .
This method returns the first substring found in that matches the regular expression pattern. You can retrieve subsequent matches by repeatedly calling the returned object's method. You can also retrieve all matches in a single method call by calling the method.
The parameter specifies how long a pattern matching method should try to find a match before it times out. Setting a time-out interval prevents regular expressions that rely on excessive backtracking from appearing to stop responding when they process input that contains near matches. For more information, see Best Practices for Regular Expressions in the .NET Framework and Backtracking. If no match is found in that time interval, the method throws a exception. overrides any default time-out value defined for the application domain in which the method executes.
Searches the input string for the first occurrence of the specified regular expression, using the specified matching options and time-out interval.
An object that contains information about the match.
The string to search for a match.
The regular expression pattern to match.
A bitwise combination of the enumeration values that provide options for matching.
A time-out interval, or to indicate that the method should not time out.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Text.RegularExpressions.MatchCollection
The method is similar to the method, except that it returns information about all the matches found in the input string, instead of a single match. It is equivalent to the following code:
code reference: System.Text.RegularExpressions.Regex.Matches#5
The collection includes only matches and terminates at the first non-match.
The regular expression pattern for which the method searches is defined by the call to one of the class constructors. For more information about the elements that can form a regular expression pattern, see Regular Expression Language Elements.
The method uses lazy evaluation to populate the returned object. Accessing members of this collection such as and causes the collection to be populated immediately. To take advantage of lazy evaluation, you should iterate the collection by using a construct such as foreach in C# and For Each…Next in Visual Basic.
Because of its lazy evaluation, calling the method does not throw a exception. However, the exception is thrown when an operation is performed on the object returned by this method, if the property is not and a matching operation exceeds the time-out interval.
Searches the specified input string for all occurrences of a regular expression.
A collection of the objects found by the search. If no matches are found, the method returns an empty collection object.
The string to search for a match.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Text.RegularExpressions.MatchCollection
The method is similar to the method, except that it returns information about all the matches found in the input string, instead of a single match. It is equivalent to the following code:
code reference: System.Text.RegularExpressions.Regex.Matches#6
The regular expression pattern for which the method searches is defined by the call to one of the class constructors. For more information about the elements that can form a regular expression pattern, see Regular Expression Language Elements.
The method uses lazy evaluation to populate the returned object. Accessing members of this collection such as and causes the collection to be populated immediately. To take advantage of lazy evaluation, you should iterate the collection by using a construct such as foreach in C# and For Each…Next in Visual Basic.
Because of its lazy evaluation, calling the method does not throw a exception. However, the exception is thrown when an operation is performed on the object returned by this method, if the property is not and a matching operation exceeds the time-out interval..
Searches the specified input string for all occurrences of a regular expression, beginning at the specified starting position in the string.
A collection of the objects found by the search. If no matches are found, the method returns an empty collection object.
The string to search for a match.
The character position in the input string at which to start the search.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Text.RegularExpressions.MatchCollection
The method is similar to the method, except that it returns information about all the matches found in the input string, instead of a single match. It is equivalent to the following code:
code reference: System.Text.RegularExpressions.Regex.Matches#7
The static Matches methods are equivalent to constructing a object with the specified regular expression pattern and calling the instance method Matches.
The parameter consists of regular expression language elements that symbolically describe the string to match. For more information about regular expressions, see .NET Framework Regular Expressions and Regular Expression Language Elements.
The method uses lazy evaluation to populate the returned object. Accessing members of this collection such as and causes the collection to be populated immediately. To take advantage of lazy evaluation, you should iterate the collection by using a construct such as foreach in C# and For Each…Next in Visual Basic.
Because of its lazy evaluation, calling the method does not throw a exception. However, the exception is thrown when an operation is performed on the object returned by this method, if a time-out interval is defined by the "REGEX_DEFAULT_MATCH_TIMEOUT" property of the current application domain and a matching operation exceeds this time-out interval.
Searches the specified input string for all occurrences of a specified regular expression.
A collection of the objects found by the search. If no matches are found, the method returns an empty collection object.
The string to search for a match.
The regular expression pattern to match.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Text.RegularExpressions.MatchCollection
The method is similar to the method, except that it returns information about all the matches found in the input string, instead of a single match. It is equivalent to the following code:
code reference: System.Text.RegularExpressions.Regex.Matches#8
The static Matches methods are equivalent to constructing a object with the specified regular expression pattern and calling the instance method Matches.
The parameter consists of regular expression language elements that symbolically describe the string to match. For more information about regular expressions, see .NET Framework Regular Expressions and Regular Expression Language Elements.
The method uses lazy evaluation to populate the returned object. Accessing members of this collection such as and causes the collection to be populated immediately. To take advantage of lazy evaluation, you should iterate the collection by using a construct such as foreach in C# and For Each…Next in Visual Basic.
Because of its lazy evaluation, calling the method does not throw a exception. However, the exception is thrown when an operation is performed on the object returned by this method, if a time-out interval is defined by the "REGEX_DEFAULT_MATCH_TIMEOUT" property of the current application domain and a matching operation exceeds this time-out interval.
Searches the specified input string for all occurrences of a specified regular expression, using the specified matching options.
A collection of the objects found by the search. If no matches are found, the method returns an empty collection object.
The string to search for a match.
The regular expression pattern to match.
A bitwise combination of the enumeration values that specify options for matching.
Method
4.0.0.0
System.MonoTODO("Timeouts are ignored.")
System.Text.RegularExpressions.MatchCollection
The method is similar to the method, except that it returns information about all the matches found in the input string, instead of a single match. It is equivalent to the following code:
code reference: System.Text.RegularExpressions.Regex.Matches#10
The static Matches methods are equivalent to constructing a object with the specified regular expression pattern and calling the instance method Matches.
The parameter consists of regular expression language elements that symbolically describe the string to match. For more information about regular expressions, see .NET Framework Regular Expressions and Regular Expression Language Elements.
The method uses lazy evaluation to populate the returned object. Accessing members of this collection such as and causes the collection to be populated immediately. To take advantage of lazy evaluation, you should iterate the collection by using a construct such as foreach in C# and For Each…Next in Visual Basic.
Because of its lazy evaluation, calling the method does not throw a exception. However, an exception is thrown when an operation is performed on the object returned by this method, if a matching operation exceeds this time-out interval specified by the parameter.
Searches the specified input string for all occurrences of a specified regular expression, using the specified matching options and time-out interval.
A collection of the objects found by the search. If no matches are found, the method returns an empty collection object.
The string to search for a match.
The regular expression pattern to match.
A bitwise combination of the enumeration values that specify options for matching.
A time-out interval, or to indicate that the method should not time out.
Property
4.0.0.0
System.MonoTODO("Timeouts are ignored.")
System.TimeSpan
To be added.
The property defines the approximate maximum time interval for a instance to execute a single matching operation before the operation times out. The regular expression engine throws a exception during its next timing check after the time-out interval has elapsed. This prevents the regular expression engine from processing input strings that require excessive backtracking. For more information, see Backtracking and Best Practices for Regular Expressions in the .NET Framework.
This property is read-only. You can set its value explicitly for an individual object by calling the constructor; and you can set its value for all matching operations in an application domain by calling the method and providing a value for the "REGEX_DEFAULT_MATCH_TIMEOUT" property. If you do not explicitly set a time-out interval, the default value is used, and matching operations do not time out.
Gets the time-out interval of the current instance.
Property
1.0.5000.0
2.0.0.0
4.0.0.0
System.Text.RegularExpressions.RegexOptions
To be added: an object of type 'RegexOptions'
The value of the property consists of one or more members of the enumeration. If no options were defined in the class constructor, its value is . The available options are discussed in detail in the Regular Expression Options topic.
Gets the options that were passed into the constructor.
Field
1.0.5000.0
2.0.0.0
4.0.0.0
System.String
To be added.
Used by a object generated by the method.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.String
The search for matches starts at the beginning of the string. The regular expression is the pattern defined by the constructor for the current object.
The parameter specifies the string that is to replace each match in . can consist of any combination of literal text and substitutions. For example, the replacement pattern a*${test}b inserts the string "a*" followed by the substring that is 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.
Substitutions are the only regular expression language elements that are recognized in a replacement pattern. All other regular expression language elements, including character escapes, are allowed in regular expression patterns only and are not recognized in replacement patterns.
The exception is thrown if the execution time of the replacement operation exceeds the time-out interval specified by the constructor. If you do not set a time-out interval when you call the constructor, the exception is thrown if the operation exceeds any time-out value established for the application domain in which the object is created. If no time-out is defined in the constructor call or in the application domain's properties, or if the time-out value is , no exception is thrown
Because the method returns unchanged if there is no match, you can use the method to determine whether the method has made any replacements to the input string.
In a specified input string, replaces all strings that match a regular expression pattern with a specified replacement string.
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.
The string to search for a match.
The replacement string.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.String
The method is useful for replacing a regular expression match if any of the following conditions is true:
-
The replacement string cannot readily be specified by a regular expression replacement pattern.
-
The replacement string results from some processing done on the matched string.
-
The replacement string results from conditional processing.
The method is equivalent to calling the method and passing each object in the returned collection to the delegate.
The regular expression is the pattern defined by the constructor for the current object.
The parameter is the delegate for a custom method that you define and that examines each match. The custom method must have the following signature to match the delegate.
code reference: System.Text.RegularExpressions.Regex.Replace#1
Your custom method returns a string that replaces the matched input.
The exception is thrown if the execution time of the replacement operation exceeds the time-out interval specified by the constructor. If you do not set a time-out interval when you call the constructor, the exception is thrown if the operation exceeds any time-out value established for the application domain in which the object is created. If no time-out is defined in the constructor call or in the application domain's properties, or if the time-out value is , no exception is thrown
Because the method returns unchanged if there is no match, you can use the method to determine whether the method has made any replacements to the input string.
In a specified input string, replaces all strings that match a specified regular expression with a string returned by a delegate.
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.
The string to search for a match.
A custom method that examines each match and returns either the original matched string or a replacement string.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.String
The search for matches starts at the beginning of the string. The regular expression is the pattern that is defined by the constructor for the current object. If is negative, replacements continue to the end of the string. If exceeds the number of matches, all matches are replaced.
The parameter specifies the string that is to replace the first matches in . can consist of any combination of literal text and substitutions. For example, the replacement pattern a*${test}b inserts the string "a*" followed by the substring that is 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.
Substitutions are the only regular expression language elements that are recognized in a replacement pattern. All other regular expression language elements, including character escapes, are allowed in regular expression patterns only and are not recognized in replacement patterns.
The exception is thrown if the execution time of the replacement operation exceeds the time-out interval specified by the constructor. If you do not set a time-out interval when you call the constructor, the exception is thrown if the operation exceeds any time-out value established for the application domain in which the object is created. If no time-out is defined in the constructor call or in the application domain's properties, or if the time-out value is , no exception is thrown
Because the method returns unchanged if there is no match, you can use the method to determine whether the method has made any replacements to the input string.
In a specified input string, replaces a specified maximum number of strings that match a regular expression pattern with a specified replacement string.
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.
The string to search for a match.
The replacement string.
The maximum number of times the replacement can occur.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.String
The static Replace methods are equivalent to constructing a object with the specified regular expression pattern and calling the instance method Replace.
The parameter consists of regular expression language elements that symbolically describe the string to match. For more information about regular expressions, see .NET Framework Regular Expressions and Regular Expression Language Elements. The search for matches starts at the beginning of the string.
The parameter specifies the string that is to replace each match in . can consist of any combination of literal text and substitutions. For example, the replacement pattern a*${test}b inserts the string "a*" followed by the substring that is 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.
Substitutions are the only regular expression language elements that are recognized in a replacement pattern. All other regular expression language elements, including character escapes, are allowed in regular expression patterns only and are not recognized in replacement patterns.
The exception is thrown if the execution time of the replacement operation exceeds the time-out interval specified for the application domain in which the method is called. If no time-out is defined in the application domain's properties, or if the time-out value is , no exception is thrown.
Because the method returns unchanged if there is no match, you can use the method to determine whether the method has made any replacements to the input string.
In a specified input string, replaces all strings that match a specified regular expression with a specified replacement string.
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.
The string to search for a match.
The regular expression pattern to match.
The replacement string.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.String
The method is useful for replacing a regular expression match if any of the following conditions is true:
-
The replacement string cannot readily be specified by a regular expression replacement pattern.
-
The replacement string results from some processing done on the matched string.
-
The replacement string results from conditional processing.
The method is equivalent to calling the method and passing each object in the returned collection to the delegate.
The parameter consists of regular expression language elements that symbolically describe the string to match. For more information about regular expressions, see .NET Framework Regular Expressions and Regular Expression Language Elements.
The parameter is the delegate for a custom method that you define and that examines each match. The custom method must have the following signature to match the delegate.
code reference: System.Text.RegularExpressions.Regex.Replace#1
Your custom method returns a string that replaces the matched input.
The exception is thrown if the execution time of the replacement operation exceeds the time-out interval specified for the application domain in which the method is called. If no time-out is defined in the application domain's properties, or if the time-out value is , no exception is thrown.
Because the method returns unchanged if there is no match, you can use the method to determine whether the method has made any replacements to the input string.
In a specified input string, replaces all strings that match a specified regular expression with a string returned by a delegate.
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.
The string to search for a match.
The regular expression pattern to match.
A custom method that examines each match and returns either the original matched string or a replacement string.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.String
The method is useful for replacing a regular expression match if any of the following conditions is true:
-
The replacement string cannot readily be specified by a regular expression replacement pattern.
-
The replacement string results from some processing done on the matched string.
-
The replacement string results from conditional processing.
The method is equivalent to calling the method and passing the first objects in the returned collection to the delegate.
The regular expression is the pattern defined by the constructor for the current object.
The parameter is the delegate for a custom method that you define and that examines each match. The custom method must have the following signature to match the delegate.
code reference: System.Text.RegularExpressions.Regex.Replace#1
Your custom method returns a string that replaces the matched input.
The exception is thrown if the execution time of the replacement operation exceeds the time-out interval specified by the constructor. If you do not set a time-out interval when you call the constructor, the exception is thrown if the operation exceeds any time-out value established for the application domain in which the object is created. If no time-out is defined in the constructor call or in the application domain's properties, or if the time-out value is , no exception is thrown
Because the method returns unchanged if there is no match, you can use the method to determine whether the method has made any replacements to the input string.
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.
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.
The string to search for a match.
A custom method that examines each match and returns either the original matched string or a replacement string.
The maximum number of times the replacement will occur.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.String
The search for matches starts in the string at the position specified by the parameter. The regular expression is the pattern defined by the constructor for the current object. If is negative, replacements continue to the end of the string. If exceeds the number of matches, all matches are replaced.
The parameter specifies the string that is to replace each match in . can consist of any combination of literal text and substitutions. For example, the replacement pattern a*${test}b inserts the string "a*" followed by the substring that is 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.
Substitutions are the only regular expression language elements that are recognized in a replacement pattern. All other regular expression language elements, including character escapes, are allowed in regular expression patterns only and are not recognized in replacement patterns.
The exception is thrown if the execution time of the replacement operation exceeds the time-out interval specified by the constructor. If you do not set a time-out interval when you call the constructor, the exception is thrown if the operation exceeds any time-out value established for the application domain in which the object is created. If no time-out is defined in the constructor call or in the application domain's properties, or if the time-out value is , no exception is thrown
Because the method returns unchanged if there is no match, you can use the method to determine whether the method has made any replacements to the input string.
In a specified input substring, replaces a specified maximum number of strings that match a regular expression pattern with a specified replacement string.
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.
The string to search for a match.
The replacement string.
Maximum number of times the replacement can occur.
The character position in the input string where the search begins.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.String
The static Replace methods are equivalent to constructing a object with the specified regular expression pattern and calling the instance method Replace.
The parameter consists of regular expression language elements that symbolically describe the string to match. For more information about regular expressions, see .NET Framework Regular Expressions and Regular Expression Language Elements. If you specify for the parameter, the search for matches begins at the end of the input string and moves left; otherwise, the search begins at the start of the input string and moves right.
The parameter specifies the string that is to replace each match in . can consist of any combination of literal text and substitutions. For example, the replacement pattern a*${test}b inserts the string "a*" followed by the substring that is 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.
Substitutions are the only regular expression language elements that are recognized in a replacement pattern. All other regular expression language elements, including character escapes, are allowed in regular expression patterns only and are not recognized in replacement patterns.
The exception is thrown if the execution time of the replacement operation exceeds the time-out interval specified for the application domain in which the method is called. If no time-out is defined in the application domain's properties, or if the time-out value is , no exception is thrown.
Because the method returns unchanged if there is no match, you can use the method to determine whether the method has made any replacements to the input string.
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.
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.
The string to search for a match.
The regular expression pattern to match.
The replacement string.
A bitwise combination of the enumeration values that provide options for matching.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.String
The method is useful for replacing a regular expression match in if any of the following conditions is true:
-
The replacement string cannot readily be specified by a regular expression replacement pattern.
-
The replacement string results from some processing done on the matched string.
-
The replacement string results from conditional processing.
The method is equivalent to calling the method and passing each object in the returned collection to the delegate.
The parameter consists of regular expression language elements that symbolically describe the string to match. For more information about regular expressions, see .NET Framework Regular Expressions and Regular Expression Language Elements.
The parameter is the delegate for a custom method that you define and that examines each match. The custom method must have the following signature to match the delegate.
code reference: System.Text.RegularExpressions.Regex.Replace#1
Your custom method returns a string that replaces the matched input.
If you specify for the parameter, the search for matches begins at the end of the input string and moves left; otherwise, the search begins at the start of the input string and moves right.
The exception is thrown if the execution time of the replacement operation exceeds the time-out interval specified for the application domain in which the method is called. If no time-out is defined in the application domain's properties, or if the time-out value is , no exception is thrown.
Because the method returns unchanged if there is no match, you can use the method to determine whether the method has made any replacements to the input string.
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.
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.
The string to search for a match.
The regular expression pattern to match.
A custom method that examines each match and returns either the original matched string or a replacement string.
A bitwise combination of the enumeration values that provide options for matching.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.String
The method is useful for replacing a regular expression match if any of the following conditions is true:
-
The replacement string cannot readily be specified by a regular expression replacement pattern.
-
The replacement string results from some processing done on the matched string.
-
The replacement string results from conditional processing.
The method is equivalent to calling the method and passing the first objects in the returned collection to the delegate.
The regular expression is the pattern defined by the constructor for the current object.
The parameter is the delegate for a custom method that you define and that examines each match. The custom method must have the following signature to match the delegate.
code reference: System.Text.RegularExpressions.Regex.Replace#1
Your custom method returns a string that replaces the matched input.
The exception is thrown if the execution time of the replacement operation exceeds the time-out interval specified by the constructor. If you do not set a time-out interval when you call the constructor, the exception is thrown if the operation exceeds any time-out value established for the application domain in which the object is created. If no time-out is defined in the constructor call or in the application domain's properties, or if the time-out value is , no exception is thrown
Because the method returns unchanged if there is no match, you can use the method to determine whether the method has made any replacements to the input string.
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.
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.
The string to search for a match.
A custom method that examines each match and returns either the original matched string or a replacement string.
The maximum number of times the replacement will occur.
The character position in the input string where the search begins.
Method
4.0.0.0
System.MonoTODO("Timeouts are ignored.")
System.String
The static Replace methods are equivalent to constructing a object with the specified regular expression pattern and calling the instance method Replace.
The parameter consists of regular expression language elements that symbolically describe the string to match. For more information about regular expressions, see .NET Framework Regular Expressions and Regular Expression Language Elements. If you specify for the parameter, the search for matches begins at the end of the input string and moves left; otherwise, the search begins at the start of the input string and moves right.
The parameter specifies the string that is to replace each match in . can consist of any combination of literal text and substitutions. For example, the replacement pattern a*${test}b inserts the string "a*" followed by the substring that is 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.
Substitutions are the only regular expression language elements that are recognized in a replacement pattern. All other regular expression language elements, including character escapes, are allowed in regular expression patterns only and are not recognized in replacement patterns.
The parameter specifies how long a pattern matching method should try to find a match before it times out. Setting a time-out interval prevents regular expressions that rely on excessive backtracking from appearing to stop responding when they process input that contains near matches. For more information, see Best Practices for Regular Expressions in the .NET Framework and Backtracking. If no match is found in that time interval, the method throws a exception. overrides any default time-out value defined for the application domain in which the method executes.
Because the method returns unchanged if there is no match, you can use the method to determine whether the method has made any replacements to the input string.
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.
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.
The string to search for a match.
The regular expression pattern to match.
The replacement string.
A bitwise combination of the enumeration values that provide options for matching.
A time-out interval, or to indicate that the method should not time out.
Method
4.0.0.0
System.MonoTODO("Timeouts are ignored.")
System.String
The method is useful for replacing a regular expression match if any of the following conditions is true:
-
If the replacement string cannot readily be specified by a regular expression replacement pattern.
-
If the replacement string results from some processing performed on the matched string.
-
If the replacement string results from conditional processing.
The method is equivalent to calling the method and passing each object in the returned collection to the delegate.
The parameter consists of regular expression language elements that symbolically describe the string to match. For more information about regular expressions, see .NET Framework Regular Expressions and Regular Expression Language Elements.
The parameter is the delegate for a custom method that you define and that examines each match. The custom method must have the following signature to match the delegate.
code reference: System.Text.RegularExpressions.Regex.Replace#1
Your custom method returns a string that replaces the matched input.
If you specify for the parameter, the search for matches begins at the end of the input string and moves left; otherwise, the search begins at the start of the input string and moves right.
The parameter specifies how long a pattern matching method should try to find a match before it times out. Setting a time-out interval prevents regular expressions that rely on excessive backtracking from appearing to "stop responding when they process input that contains near matches. For more information, see Best Practices for Regular Expressions in the .NET Framework and Backtracking. If no match is found in that time interval, the method throws a exception. overrides any default time-out value defined for the application domain in which the method executes.
Because the method returns unchanged if there is no match, you can use the method to determine whether the method has made any replacements to the input string.
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.
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.
The string to search for a match.
The regular expression pattern to match.
A custom method that examines each match and returns either the original matched string or a replacement string.
A bitwise combination of enumeration values that provide options for matching.
A time-out interval, or to indicate that the method should not time out.
Property
1.0.5000.0
2.0.0.0
4.0.0.0
System.Boolean
To be added: an object of type 'bool'
is true if the instance was created with the option.
Gets a value that indicates whether the regular expression searches from right to left.
Field
1.0.5000.0
2.0.0.0
4.0.0.0
System.Text.RegularExpressions.RegexOptions
To be added.
Used by a object generated by the method.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.String[]
The methods are similar to the method, except that splits the string at a delimiter determined by a regular expression instead of a set of characters. The string is split as many times as possible. If no delimiter is found, the return value contains one element whose value is the original input string.
If multiple matches are adjacent to one another, an empty string is inserted into the array. For example, splitting a string on a single hyphen causes the returned array to include an empty string in the position where two adjacent hyphens are found, as the following code shows.
code reference: System.Text.RegularExpressions.Regex.Split#1
If a match is found at the beginning or the end of the input string, an empty string is included at the beginning or the end of the returned array. The following example uses the regular expression pattern \d+ to split an input string on numeric characters. Because the string begins and ends with matching numeric characters, the value of the first and last element of the returned array is .
code reference: System.Text.RegularExpressions.Regex.Split#21
If capturing parentheses are used in a expression, any captured text is included in the resulting string array. For example, if you split the string "plum-pear" on a hyphen placed within capturing parentheses, the returned array includes a string element that contains the hyphen.
code reference: System.Text.RegularExpressions.Regex.Split#2
However, when the regular expression pattern includes multiple sets of capturing parentheses, the behavior of this method depends on the version of the .NET Framework. In the .NET Framework 1.0 and 1.1, if a match is not found within the first set of capturing parentheses, captured text from additional capturing parentheses is not included in the returned array. Starting with the .NET Framework 2.0, all captured text is also added to the returned array. For example, the following code uses two sets of capturing parentheses to extract the elements of a date, including the date delimiters, from a date string. The first set of capturing parentheses captures the hyphen, and the second set captures the forward slash. If the example code is compiled and run under the .NET Framework 1.0 or 1.1, it excludes the slash characters; if it is compiled and run under the .NET Framework 2.0 or later versions, it includes them.
code reference: System.Text.RegularExpressions.Regex.Split#3
If the regular expression can match the empty string, will split the string into an array of single-character strings because the empty string delimiter can be found at every location. For example:
code reference: System.Text.RegularExpressions.Regex.Split#11
Note that the returned array also includes an empty string at the beginning and end of the array.
The exception is thrown if the execution time of the split operation exceeds the time-out interval specified by the constructor. If you do not set a time-out interval when you call the constructor, the exception is thrown if the operation exceeds any time-out value established for the application domain in which the object is created. If no time-out is defined in the constructor call or in the application domain's properties, or if the time-out value is , no exception is thrown
Splits an input string into an array of substrings at the positions defined by a regular expression pattern specified in the constructor.
An array of strings.
The string to split.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.String[]
The methods are similar to the method, except that splits the string at a delimiter determined by a regular expression instead of a set of characters. The parameter specifies the maximum number of substrings into which the string can be split; the last string contains the unsplit remainder of the string. A value of zero provides the default behavior of splitting as many times as possible.
If multiple matches are adjacent to one another or if a match is found at the beginning or end of , and the number of matches found is at least two less than , an empty string is inserted into the array. That is, empty strings that result from adjacent matches or from matches at the beginning or end of the input string are counted in determining whether the number of matched substrings equals . In the following example, the regular expression /d+ is used to split an input string that includes one or more decimal digits into a maximum of three substrings. Because the beginning of the input string matches the regular expression pattern, the first array element contains , the second contains the first set of alphabetic characters in the input string, and the third contains the remainder of the string that follows the third match.
code reference: System.Text.RegularExpressions.Regex.Split#25
If capturing parentheses are used in a regular expression, any captured text is included in the array of split strings. However, any array elements that contain captured text are not counted in determining whether the number of matches has reached . For example, splitting the string "apple-apricot-plum-pear-banana" into a maximum of four substrings results in a seven-element array, as the following code shows.
code reference: System.Text.RegularExpressions.Regex.Split#4
However, when the regular expression pattern includes multiple sets of capturing parentheses, the behavior of this method depends on the version of the .NET Framework. In the .NET Framework 1.0 and 1.1, only captured text from the first set of capturing parentheses is included in the returned array. Starting with the .NET Framework 2.0, all captured text is added to the returned array. However, elements in the returned array that contain captured text are not counted in determining whether the number of matched substrings equals . For example, in the following code, a regular expression uses two sets of capturing parentheses to extract the elements of a date from a date string. The first set of capturing parentheses captures the hyphen, and the second set captures the forward slash. The call to the method then specifies a maximum of two elements in the returned array. If the example code is compiled and run under the .NET Framework 1.0 or 1.1, the method returns a two-element string array. If it is compiled and run under the .NET Framework 2.0 or later versions, the method returns a three-element string array.
code reference: System.Text.RegularExpressions.Regex.Split#5
If the regular expression can match the empty string, will split the string into an array of single-character strings because the empty string delimiter can be found at every location. The following example splits the string "characters" into as many elements as there are in the input string. Because the null string matches the beginning of the input string, a null string is inserted at the beginning of the returned array. This causes the tenth element to consist of the two characters at the end of the input string.
code reference: System.Text.RegularExpressions.Regex.Split#12
The exception is thrown if the execution time of the split operation exceeds the time-out interval specified by the constructor. If you do not set a time-out interval when you call the constructor, the exception is thrown if the operation exceeds any time-out value established for the application domain in which the object is created. If no time-out is defined in the constructor call or in the application domain's properties, or if the time-out value is , no exception is thrown
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.
An array of strings.
The string to be split.
The maximum number of times the split can occur.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.String[]
The methods are similar to the method, except that splits the string at a delimiter determined by a regular expression instead of a set of characters. The string is split as many times as possible. If is not found in the string, the return value contains one element whose value is the original string.
The parameter consists of regular expression language elements that symbolically describe the string to match. For more information about regular expressions, see .NET Framework Regular Expressions and Regular Expression Language Elements.
Compiled regular expressions used in calls to static methods are automatically cached. To manage the lifetime of compiled regular expressions yourself, use the instance methods.
If multiple matches are adjacent to one another, an empty string is inserted into the array. For example, splitting a string on a single hyphen causes the returned array to include an empty string in the position where two adjacent hyphens are found, as the following code shows.
code reference: System.Text.RegularExpressions.Regex.Split#8
If a match is found at the beginning or the end of the input string, an empty string is included at the beginning or the end of the returned array. The following example uses the regular expression pattern \d+ to split an input string on numeric characters. Because the string begins and ends with matching numeric characters, the value of the first and last element of the returned array is .
code reference: System.Text.RegularExpressions.Regex.Split#22
If capturing parentheses are used in a expression, any captured text is included in the resulting string array. For example, if you split the string "plum-pear" on a hyphen placed within capturing parentheses, the returned array includes a string element that contains the hyphen.
code reference: System.Text.RegularExpressions.Regex.Split#9
However, when the regular expression pattern includes multiple sets of capturing parentheses, the behavior of this method depends on the version of the .NET Framework. In the .NET Framework 1.0 and 1.1, if a match is not found within the first set of capturing parentheses, captured text from additional capturing parentheses is not included in the returned array. Starting with the .NET Framework 2.0, all captured text is also added to the returned array. For example, the following code uses two sets of capturing parentheses to extract the elements of a date, including the date delimiters, from a date string. The first set of capturing parentheses captures the hyphen, and the second set captures the forward slash. If the example code is compiled and run under the .NET Framework 1.0 or 1.1, it excludes the slash characters; if it is compiled and run under the .NET Framework 2.0 or later versions, it includes them.
code reference: System.Text.RegularExpressions.Regex.Split#10
If the regular expression can match the empty string, will split the string into an array of single-character strings because the empty string delimiter can be found at every location. For example:
code reference: System.Text.RegularExpressions.Regex.Split#13
Note that the returned array also includes an empty string at the beginning and end of the array.
The exception is thrown if the execution time of the split operation exceeds the time-out interval specified for the application domain in which the method is called. If no time-out is defined in the application domain's properties, or if the time-out value is , no exception is thrown.
Splits an input string into an array of substrings at the positions defined by a regular expression pattern.
An array of strings.
The string to split.
The regular expression pattern to match.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.String[]
The methods are similar to the method, except that splits the string at a delimiter determined by a regular expression instead of a set of characters. The parameter specifies the maximum number of substrings into which the string is split; the last string contains the unsplit remainder of the string. A value of zero provides the default behavior of splitting as many times as possible. The parameter defines the point at which the search for the first delimiter begins (this can be used for skipping leading white space).
If no matches are found from the +1 position in the string, the method returns a one-element array that contains the string. If one or more matches are found, the first element of the returned array contains the first portion of the string from the first character up to one character before the match.
If multiple matches are adjacent to one another and the number of matches found is at least two less than , an empty string is inserted into the array. Similarly, if a match is found at , which is the first character in the string, the first element of the returned array is an empty string. That is, empty strings that result from adjacent matches are counted in determining whether the number of matched substrings equals . In the following example, the regular expression \d+ is used to find the starting position of the first substring of numeric characters in a string, and then to split the string a maximum of three times starting at that position. Because the regular expression pattern matches the beginning of the input string, the returned string array consists of an empty string, a five-character alphabetic string, and the remainder of the string,
code reference: System.Text.RegularExpressions.Regex.Split#26
If capturing parentheses are used in a regular expression, any captured text is included in the array of split strings. However, any array elements that contain captured text are not counted in determining whether the number of matches has reached . For example, splitting the string '"apple-apricot-plum-pear-pomegranate-pineapple-peach" into a maximum of four substrings beginning at character 15 in the string results in a seven-element array, as the following code shows.
code reference: System.Text.RegularExpressions.Regex.Split#6
However, when the regular expression pattern includes multiple sets of capturing parentheses, the behavior of this method depends on the version of the .NET Framework. In .NET Framework 1.0 and 1.1, if a match is not found within the first set of capturing parentheses, captured text from additional capturing parentheses is not included in the returned array. Starting with the .NET Framework 2.0, all captured text is also added to the returned array. For example, the following code uses two sets of capturing parentheses to extract the individual words in a string. The first set of capturing parentheses captures the hyphen, and the second set captures the vertical bar. If the example code is compiled and run under the .NET Framework 1.0 or 1.1, it excludes the vertical bar characters; if it is compiled and run under the .NET Framework 2.0 or later versions, it includes them.
code reference: System.Text.RegularExpressions.Regex.Split#7
If the regular expression can match the empty string, will split the string into an array of single-character strings because the empty string delimiter can be found at every location. The following example splits the string "characters" into as many elements as the input string contains, starting with the character "a". Because the null string matches the end of the input string, a null string is inserted at the end of the returned array.
code reference: System.Text.RegularExpressions.Regex.Split#14
The exception is thrown if the execution time of the split operation exceeds the time-out interval specified by the constructor. If you do not set a time-out interval when you call the constructor, the exception is thrown if the operation exceeds any time-out value established for the application domain in which the object is created. If no time-out is defined in the constructor call or in the application domain's properties, or if the time-out value is , no exception is thrown
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.
An array of strings.
The string to be split.
The maximum number of times the split can occur.
The character position in the input string where the search will begin.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.String[]
The methods are similar to the method, except that splits the string at a delimiter determined by a regular expression instead of a set of characters. The string is split as many times as possible. If no delimiter is found, the return value contains one element whose value is the original string.
The parameter consists of regular expression language elements that symbolically describe the string to match. For more information about regular expressions, see .NET Framework Regular Expressions and Regular Expression Language Elements.
Compiled regular expressions used in calls to static methods are automatically cached. To manage the lifetime of compiled regular expressions yourself, use the instance methods.
If multiple matches are adjacent to one another, an empty string is inserted into the array. For example, splitting a string on a single hyphen causes the returned array to include an empty string in the position where two adjacent hyphens are found.
If a match is found at the beginning or the end of the input string, an empty string is included at the beginning or the end of the returned array. The following example uses the regular expression pattern [a-z]+ to split an input string on any uppercase or lowercase alphabetic character. Because the string begins and ends with matching alphabetic characters, the value of the first and last element of the returned array is .
code reference: System.Text.RegularExpressions.Regex.Split#24
If capturing parentheses are used in a expression, any captured text is included in the resulting string array. For example, if you split the string "plum-pear" on a hyphen placed within capturing parentheses, the returned array includes a string element that contains the hyphen.
code reference: System.Text.RegularExpressions.Regex.Split#9
However, when the regular expression pattern includes multiple sets of capturing parentheses, the behavior of this method depends on the version of the .NET Framework. In the .NET Framework 1.0 and 1.1, if a match is not found within the first set of capturing parentheses, captured text from additional capturing parentheses is not included in the returned array. Starting with the .NET Framework 2.0, all captured text is also added to the returned array. For example, the following code uses two sets of capturing parentheses to extract the elements of a date, including the date delimiters, from a date string. The first set of capturing parentheses captures the hyphen, and the second set captures the forward slash. If the example code is compiled and run under the .NET Framework 1.0 or 1.1, it excludes the slash characters; if it is compiled and run under the .NET Framework 2.0 or later versions, it includes them.
code reference: System.Text.RegularExpressions.Regex.Split#10
If the regular expression can match the empty string, will split the string into an array of single-character strings because the empty string delimiter can be found at every location.
The exception is thrown if the execution time of the split operation exceeds the time-out interval specified for the application domain in which the method is called. If no time-out is defined in the application domain's properties, or if the time-out value is , no exception is thrown.
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.
An array of strings.
The string to split.
The regular expression pattern to match.
A bitwise combination of the enumeration values that provide options for matching.
Method
4.0.0.0
System.MonoTODO("Timeouts are ignored.")
System.String[]
The methods are similar to the method, except that splits the string at a delimiter determined by a regular expression instead of a set of characters. The string is split as many times as possible. If no delimiter is found, the return value contains one element whose value is the original string.
The parameter consists of regular expression language elements that symbolically describe the string to match. For more information about regular expressions, see .NET Framework Regular Expressions and Regular Expression Language Elements.
Compiled regular expressions used in calls to static methods are automatically cached. To manage the lifetime of compiled regular expressions yourself, use the instance methods.
If multiple matches are adjacent to one another, an empty string is inserted into the array. For example, splitting a string on a single hyphen causes the returned array to include an empty string in the position where two adjacent hyphens are found.
If a match is found at the beginning or the end of the input string, an empty string is included at the beginning or the end of the returned array. The following example uses the regular expression pattern [a-z]+ to split an input string on any uppercase or lowercase alphabetic character. Because the string begins and ends with matching alphabetic characters, the value of the first and last element of the returned array is .
code reference: System.Text.RegularExpressions.Regex.Split#23
If capturing parentheses are used in a expression, any captured text is included in the resulting string array. For example, if you split the string "plum-pear" on a hyphen placed within capturing parentheses, the returned array includes a string element that contains the hyphen.
code reference: System.Text.RegularExpressions.Regex.Split#9
However, when the regular expression pattern includes multiple sets of capturing parentheses, the behavior of this method depends on the version of the .NET Framework. In the .NET Framework 1.0 and 1.1, if a match is not found within the first set of capturing parentheses, captured text from additional capturing parentheses is not included in the returned array. Starting with the .NET Framework 2.0, all captured text is also added to the returned array. For example, the following code uses two sets of capturing parentheses to extract the elements of a date, including the date delimiters, from a date string. The first set of capturing parentheses captures the hyphen, and the second set captures the forward slash. If the example code is compiled and run under the .NET Framework 1.0 or 1.1, it excludes the slash characters; if it is compiled and run under the .NET Framework 2.0 or later versions, it includes them.
code reference: System.Text.RegularExpressions.Regex.Split#10
If the regular expression can match the empty string, will split the string into an array of single-character strings because the empty string delimiter can be found at every location.
The parameter specifies how long a pattern matching method should try to find a match before it times out. Setting a time-out interval prevents regular expressions that rely on excessive backtracking from appearing to stop responding when they process input that contains near matches. For more information, see Best Practices for Regular Expressions in the .NET Framework and Backtracking. If no match is found in that time interval, the method throws a exception. overrides any default time-out value defined for the application domain in which the method executes.
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.
A string array.
The string to split.
The regular expression pattern to match.
A bitwise combination of the enumeration values that provide options for matching.
A time-out interval, or to indicate that the method should not time out.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Void
To be added.
To be added.
Populates a object with the data necessary to deserialize the current object.
The place to store and retrieve serialized data. This parameter is reserved for future use.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.String
The parameter consists of regular expression language elements that symbolically describe the string to match. For more information about regular expressions, see .NET Framework Regular Expressions and Regular Expression Language Elements.
Returns the regular expression pattern that was passed into the Regex constructor.
The parameter that was passed into the Regex constructor.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.String
The method performs one of the following two transformations:
-
It reverses the transformation performed by the method by removing the escape character ("\") from each character escaped by the method. These include the \, *, +, ?, |, {, [, (,), ^, $,., #, and white space characters. In addition, the method unescapes the closing bracket (]) and closing brace (}) characters.
cannot reverse an escaped string perfectly because it cannot deduce precisely which characters were escaped,
-
It replaces the representation of unprintable characters with the characters themselves. For example, it replaces \a with \x07. The character representations it replaces are \a, \b, \e, \n, \r, \f, \t, and \v.
If the method encounters other escape sequences that it cannot convert, such as \w or \s, it throws an .
Converts any escaped characters in the input string.
A string of characters with any escaped characters converted to their unescaped form.
The input string containing the text to convert.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Boolean
To be added
Used by a object generated by the method.
true if the property contains the option; otherwise, false.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Boolean
To be added
Used by a object generated by the method.
true if the property contains the option; otherwise, false.