A System.Text.RegularExpressions.RegexOptions value can be provided as a parameter to the following members of the System.Text.RegularExpressions.Regex class:
The Regex.#ctor(string, RegexOptions) class constructor.
The Regex.Split(string, string, RegexOptions) method.
The Regex.IsMatch(string, string, RegexOptions) method.
The Regex.Match(string, string, RegexOptions) method.
The Regex.Matches(string, string, RegexOptions) method.
The Regex.Replace(string, string, string, RegexOptions) and Regex.Replace(string, string, MatchEvaluator, RegexOptions) methods.
A System.Text.RegularExpressions.RegexOptions value can also be supplied as a parameter to the RegexCompilationInfo.#ctor(string, RegexOptions, string, string, bool) constructor, or it can be assigned directly to the RegexCompilationInfo.Options property. The resulting System.Text.RegularExpressions.RegexCompilationInfo object is then used in the call to the Regex.CompileToAssembly(RegexCompilationInfo[], System.Reflection.AssemblyName, System.Reflection.Emit.CustomAttributeBuilder[], string) method.
Several options provided by members of the System.Text.RegularExpressions.RegexOptions enumeration (in particular, by its RegexOptions.ExplicitCapture, RegexOptions.IgnoreCase, RegexOptions.Multiline, and RegexOptions.Singleline members) can instead be provided by using an inline option character in the regular expression pattern. For details, see Regular Expression Options.
Member Name | Description |
---|---|
Compiled |
Specifies that the regular expression is compiled to an assembly. This yields faster execution but increases startup time. This value should not be assigned to the RegexCompilationInfo.Options property when calling the Regex.CompileToAssembly(RegexCompilationInfo[], System.Reflection.AssemblyName) method. |
CultureInvariant |
Specifies that cultural differences in language is ignored. See Regular Expression Options for more information. |
ECMAScript |
Enables ECMAScript-compliant behavior for the expression. This value can be used only in conjunction with the RegexOptions.IgnoreCase, RegexOptions.Multiline, and RegexOptions.Compiled values. The use of this value with any other values results in an exception. |
ExplicitCapture |
Specifies that the only valid captures are explicitly named or numbered groups of the form (?<name>…). This allows unnamed parentheses to act as noncapturing groups without the syntactic clumsiness of the expression (?:…). |
IgnoreCase |
Specifies case-insensitive matching. |
IgnorePatternWhitespace |
Eliminates unescaped white space from the pattern and enables comments marked with #. However, the RegexOptions.IgnorePatternWhitespace value does not affect or eliminate white space in character classes. |
Multiline |
Multiline mode. Changes the meaning of ^ and $ so they match at the beginning and end, respectively, of any line, and not just the beginning and end of the entire string. |
None |
Specifies that no options are set. |
RightToLeft |
Specifies that the search will be from right to left instead of from left to right. |
Singleline |
Specifies single-line mode. Changes the meaning of the dot (.) so it matches every character (instead of every character except \n). |