

The Regex.Match(String, String, RegexOptions) method. The Regex.IsMatch(String, String, RegexOptions) method. The Regex.Split(String, String, RegexOptions) method. The Regex.Regex(String, RegexOptions) class constructor. ' The the quick brown fox fox jumps over the lazy dog dog.Ī RegexOptions value can be provided as a parameter to the following members of the Regex class: ' The example produces the following output to the console: MatchCollection matches = rxInsensitive.Matches(text) Ĭonsole.WriteLine("", _ Find matches using case-insensitive regular expression.

String text = "The the quick brown fox fox jumps over the lazy dog dog." Regex rxSensitive = new Define a test string. Define a case-sensitive regular expression for repeated words. Regex rxInsensitive = new | RegexOptions.IgnoreCase) Define a case-insensitive regular expression for repeated words. The second regular expression is case-sensitive a word must match the case of the preceding word exactly to be considered a duplicate. The first regular expression is case-insensitive case is ignored when determining whether a word is identical to the preceding word. The following example defines two regular expressions that identify repeated words in text but that are instantiated using different RegexOptions values. For more information, see the "Single-line Mode" section in the Regular Expression Options article. Changes the meaning of the dot (.) so it matches every character (instead of every character except \n). For more information, see the "Right-to-Left Mode" section in the Regular Expression Options article. Specifies that the search will be from right to left instead of from left to right. For more information about the default behavior of the regular expression engine, see the "Default Options" section in the Regular Expression Options article. For more information, see the "Multiline Mode" section in the Regular Expression Options article.Įnable matching using an approach that avoids backtracking and guarantees linear-time processing in the length of the input. 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 "Ignore White Space" section of the Regular Expression Options article. 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 "Case-Insensitive Matching " section in the Regular Expression Options article.Įliminates unescaped white space from the pattern and enables comments marked with #. For more information, see the "Explicit Captures Only" section in the Regular Expression Options article. This allows unnamed parentheses to act as noncapturing groups without the syntactic clumsiness of the expression (?.). Specifies that the only valid captures are explicitly named or numbered groups of the form (?.). The use of this value with any other values results in an exception.įor more information on the ECMAScript option, see the "ECMAScript Matching Behavior" section in the Regular Expression Options article. This value can be used only in conjunction with the IgnoreCase, Multiline, and Compiled values. For more information, see the "Comparison Using the Invariant Culture" section in the Regular Expression Options article.Įnables ECMAScript-compliant behavior for the expression. Specifies that cultural differences in language is ignored.

For more information, see the "Compiled Regular Expressions" section in the Regular Expression Options article. This value should not be assigned to the Options property when calling the CompileToAssembly(RegexCompilationInfo, AssemblyName) method. Compiled regular expressions maximize run-time performance at the expense of initialization time. Specifies that the regular expression is compiled to MSIL code, instead of being interpreted.
