0 out of 6 rated this helpful - Rate this topic

RegexOptions Enumeration

Provides enumerated values to use to set regular expression options.

This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.

Namespace: System.Text.RegularExpressions
Assembly: System (in system.dll)

[FlagsAttribute] 
public enum RegexOptions
/** @attribute FlagsAttribute() */ 
public enum RegexOptions
FlagsAttribute 
public enum RegexOptions
  Member name Description
Supported by the .NET Compact Framework Compiled Specifies that the regular expression is compiled to an assembly. This yields faster execution but increases startup time. 
Supported by the .NET Compact Framework CultureInvariant Specifies that cultural differences in language is ignored. See Performing Culture-Insensitive Operations in the RegularExpressions Namespace for more information. 
Supported by the .NET Compact Framework ECMAScript 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. 
Supported by the .NET Compact Framework 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 (?:…). 
Supported by the .NET Compact Framework IgnoreCase Specifies case-insensitive matching. 
Supported by the .NET Compact Framework IgnorePatternWhitespace Eliminates unescaped white space from the pattern and enables comments marked with #. However, the IgnorePatternWhitespace value does not affect or eliminate white space in character classes.  
Supported by the .NET Compact Framework 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. 
Supported by the .NET Compact Framework None Specifies that no options are set. 
Supported by the .NET Compact Framework RightToLeft Specifies that the search will be from right to left instead of from left to right. 
Supported by the .NET Compact Framework Singleline Specifies single-line mode. Changes the meaning of the dot (.) so it matches every character (instead of every character except \n). 

The following example illustrates the application of this enumeration to a Regex instance.

// Define a regular expression for repeated words.
Regex rx = new Regex(@"\b(?<word>\w+)\s+(\k<word>)\b",
  RegexOptions.Compiled | RegexOptions.IgnoreCase);

// Define a regular expression for repeated words.
Regex rx = new Regex("\\b(?<word>\\w+)\\s+(\\k<word>)\\b", 
    RegexOptions.Compiled | RegexOptions.IgnoreCase);

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ