Export (0) Print
Expand All

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 nameDescription
Supported by the .NET Compact FrameworkCompiledSpecifies 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 Options property when calling the CompileToAssembly method.  
Supported by the .NET Compact FrameworkCultureInvariantSpecifies that cultural differences in language is ignored. See Performing Culture-Insensitive Operations in the RegularExpressions Namespace for more information. 
Supported by the .NET Compact FrameworkECMAScriptEnables 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 FrameworkExplicitCaptureSpecifies 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 FrameworkIgnoreCaseSpecifies case-insensitive matching. 
Supported by the .NET Compact FrameworkIgnorePatternWhitespaceEliminates 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 FrameworkMultilineMultiline 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 FrameworkNoneSpecifies that no options are set. 
Supported by the .NET Compact FrameworkRightToLeftSpecifies that the search will be from right to left instead of from left to right. 
Supported by the .NET Compact FrameworkSinglelineSpecifies single-line mode. Changes the meaning of the dot (.) so it matches every character (instead of every character except \n). 

A RegexOptions value can be provided as a parameter to the following members of the Regex class:

A RegexOptions value can also be supplied as a parameter to the RegexCompilationInfo constructor, or it can be assigned directly to the Options property. The resulting RegexCompilationInfo object is then used in the call to the CompileToAssembly method.

Several options provided by members of the 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.

The following example defines two regular expressions that identify repeated words in text but that are instantiated using different RegexOptions values. The first regular expression is case-insensitive; case is ignored when determining whether a word is identical to the preceding word. The second regular expression is case-sensitive; a word must match the case of the preceding word exactly to be considered a duplicate.

Windows 98, Windows Server 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 Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

XNA Framework

Supported in: 1.0

Community Additions

ADD
Show:
© 2014 Microsoft