RegexOptions Enum

Definition

Provides enumerated values to use to set regular expression options.

This enumeration supports a bitwise combination of its member values.

public enum class RegexOptions
[System.Flags]
public enum RegexOptions
[<System.Flags>]
type RegexOptions = 
Public Enum RegexOptions
Inheritance
RegexOptions
Attributes

Fields

Name Value Description
None 0

Specifies that no options are set. For more information about the default behavior of the regular expression engine, see the "Default Options" section in the Regular Expression Options article.

IgnoreCase 1

Specifies case-insensitive matching. For more information, see the "Case-Insensitive Matching" section in the Regular Expression Options article.

Multiline 2

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. For more information, see the "Multiline Mode" section in the Regular Expression Options article.

ExplicitCapture 4

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 (?:...). For more information, see the "Explicit Captures Only" section in the Regular Expression Options article.

Compiled 8

Specifies that the regular expression is compiled to MSIL code, instead of being interpreted. Compiled regular expressions maximize run-time performance at the expense of initialization time. For more information, see the "Compiled Regular Expressions" section in the Regular Expression Options article.

Singleline 16

Specifies single-line mode. Changes the meaning of the dot (.) so it matches every character (instead of every character except \n). For more information, see the "Single-line Mode" section in the Regular Expression Options article.

IgnorePatternWhitespace 32

Eliminates unescaped white space from the pattern and enables comments marked with #. However, this value does not affect or eliminate white space in character classes, numeric quantifiers, or tokens that mark the beginning of individual regular expression language elements. For more information, see the "Ignore White Space" section of the Regular Expression Options article.

RightToLeft 64

Specifies that the search will be from right to left instead of from left to right. For more information, see the "Right-to-Left Mode" section in the Regular Expression Options article.

ECMAScript 256

Enables ECMAScript-compliant behavior for the expression. This value can be used only in conjunction with the IgnoreCase, Multiline, and Compiled values. The use of this value with any other values results in an exception.

CultureInvariant 512

Specifies that cultural differences in language are ignored. For more information, see the "Comparison Using the Invariant Culture" section in the Regular Expression Options article.

NonBacktracking 1024

Enable matching using an approach that avoids backtracking and guarantees linear-time processing in the length of the input. For more information, see the Regular Expression Options article.

AnyNewLine 2048

Make ^, $, \Z, and . recognize all common newline sequences (\r\n, \r, \n, \v (VT), \f (FF), and the Unicode newlines \u0085, \u2028, \u2029) instead of only \n. For more information, see the Regular Expression Options article.

Remarks

Several options provided by members of the RegexOptions enumeration (in particular, ExplicitCapture, IgnoreCase, Multiline, and Singleline) can instead be provided by using an inline option character in the regular expression pattern. For details, see Regular Expression Options.

Applies to

See also