Regex Constructor (String, RegexOptions)
Assembly: System (in system.dll)
public Regex ( String pattern, RegexOptions options )
public function Regex ( pattern : String, options : RegexOptions )
Parameters
- pattern
The regular expression pattern to match.
- options
A bitwise OR combination of RegexOptions enumeration values.
The pattern parameter consists of various regular expression language elements that symbolically describe the string to match. For more information about regular expressions, see the .NET Framework Regular Expressions and Regular Expression Language Elements topics.
A Regex object is immutable, which means that it can be used only for the match parameters defined when it is created. It can be used any number of times without being recompiled, however.
The following code example illustrates the use of this constructor to instantiate a regular expression with a specified pattern and options.
// 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.