Skip to content

Regex Constructors

Definition

Namespace: Corvus.Ecma262.RegularExpressions
Assembly: Corvus.Regex.Ecma262.dll

Overloads

Constructor Description
Regex(string) Initializes a new instance of the Regex class with no flags.
Regex(string, RegexFlags) Initializes a new instance of the Regex class.
Regex(string, string) Initializes a new instance of the Regex class, with the flags as new RegExp(pattern, flags) takes them.
Regex(string, RegexFlags, TimeSpan) Initializes a new instance of the Regex class with a match timeout.
Regex(string, RegexFlags, TimeSpan, GeneratedRunner?, GeneratedRunner?) Initializes a new instance of the Regex class whose programs run as the generated code given rather than the interpreter: the seam for the sou...

Regex(string)

Source: Regex.cs

Initializes a new instance of the Regex class with no flags.

public Regex(string pattern)

Parameters

Name Type Description
pattern string The pattern.

Exceptions

Exception Description
RegexParseException The pattern is not valid.
RegexPatternTooLargeException The pattern is over a limit of size.

Applies To

Product Versions
.NET 9, 10
.NET Standard 2.0, 2.1

Regex(string, RegexFlags)

Source: Regex.cs

Initializes a new instance of the Regex class.

public Regex(string pattern, RegexFlags flags)

Parameters

Name Type Description
pattern string The pattern.
flags RegexFlags The flags.

Exceptions

Exception Description
RegexParseException The pattern is not valid in the grammar of its flags.
RegexPatternTooLargeException The pattern is over a limit of size.

Applies To

Product Versions
.NET 9, 10
.NET Standard 2.0, 2.1

Regex(string, string)

Source: Regex.cs

Initializes a new instance of the Regex class, with the flags as new RegExp(pattern, flags) takes them.

public Regex(string pattern, string flags)

Parameters

Name Type Description
pattern string The pattern.
flags string The flags: any of d, g, i, m, s, u, v and y, each at most once.

Exceptions

Exception Description
RegexParseException The pattern is not valid in the grammar of its flags, or the flags are not valid.
RegexPatternTooLargeException The pattern is over a limit of size.

Applies To

Product Versions
.NET 9, 10
.NET Standard 2.0, 2.1

Regex(string, RegexFlags, TimeSpan)

Source: Regex.cs

Initializes a new instance of the Regex class with a match timeout.

public Regex(string pattern, RegexFlags flags, TimeSpan matchTimeout)

Parameters

Name Type Description
pattern string The pattern.
flags RegexFlags The flags.
matchTimeout TimeSpan The time a match may take before it is abandoned with RegexMatchTimeoutException, or InfiniteMatchTimeout.

Exceptions

Exception Description
RegexParseException The pattern is not valid in the grammar of its flags.
RegexPatternTooLargeException The pattern is over a limit of size.

Applies To

Product Versions
.NET 9, 10
.NET Standard 2.0, 2.1

Regex(string, RegexFlags, TimeSpan, GeneratedRunner?, GeneratedRunner?)

Source: Regex.cs

Initializes a new instance of the Regex class whose programs run as the generated code given rather than the interpreter: the seam for the source generator, not for use by hand.

public Regex(string pattern, RegexFlags flags, TimeSpan matchTimeout, GeneratedRunner? bounds, GeneratedRunner? captures)

Parameters

Name Type Description
pattern string The pattern.
flags RegexFlags The flags.
matchTimeout TimeSpan The limit of time on a match.
bounds GeneratedRunner? The generated code for the program that finds a match's bounds, or null.
captures GeneratedRunner? The generated code for the program that tracks every group, or null.

Applies To

Product Versions
.NET 9, 10
.NET Standard 2.0, 2.1

Collaborate with us on GitHub

The source for this content can be found on GitHub, where you can also create and review issues and pull requests.

Open an issue