RegexCompilationInfo Constructor (String^, RegexOptions, String^, String^, Boolean)

 

Initializes a new instance of the RegexCompilationInfo class that contains information about a regular expression to be included in an assembly.

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

public:
RegexCompilationInfo(
	String^ pattern,
	RegexOptions options,
	String^ name,
	String^ fullnamespace,
	bool ispublic
)

Parameters

pattern
Type: System::String^

The regular expression to compile.

options
Type: System.Text.RegularExpressions::RegexOptions

The regular expression options to use when compiling the regular expression.

name
Type: System::String^

The name of the type that represents the compiled regular expression.

fullnamespace
Type: System::String^

The namespace to which the new type belongs.

ispublic
Type: System::Boolean

true to make the compiled regular expression publicly visible; otherwise, false.

Exception Condition
ArgumentException

name is String::Empty.

ArgumentNullException

pattern is null.

-or-

name is null.

-or-

fullnamespace is null.

Each parameter of the RegexCompilationInfo(String^, RegexOptions, String^, String^, Boolean) constructor directly corresponds to a property of the RegexCompilationInfo class. Because all properties are read/write, their values can also be assigned directly.

The CompileToAssembly method generates an assembly that contains compiled regular expressions. Therefore, you should not specify Compiled as one of the values of options.

If ispublic is true, the compiled regular expression class is given public accessibility. That is, it can be instantiated from code that executes in any assembly. If ispublic is false, the compiled regular expression class is given internal (in C#) or Friend (in Visual Basic) accessibility. That is, it can be instantiated only from code that executes in the same assembly as the regular expression class.

Notes to Callers:

This constructor creates a compiled regular expression that uses the default time-out value of the application domain in which it is created. If a time-out value is defined for the application domain, the compiled regular expression uses the value Regex::InfiniteMatchTimeout, which prevents a pattern-matching operation from timing out. The recommended constructor for creating a compiled regular expression is RegexCompilationInfo(String^, RegexOptions, String^, String^, Boolean, TimeSpan), which lets you set the time-out interval.

The following example creates and uses a compiled regular expression in two steps.

In the first step, compile and execute the following code example. The RegexCompilationInfo constructor in the code example defines a compiled regular expression. The result of executing the code is an assembly named FishRegex.dll that contains a compiled regular expression type named FishRegex.

No code example is currently available or this language may not be supported.

In the second step, compile the following code example using a reference to FishRegex.dll, and then run the resulting executable file. The executable file matches a target string by using the FishRegex type, and displays the match, group, capture group, and index position of the matches in the target string.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 1.1
Return to top
Show: