Skip to content

Regex.TryCreate Method

Definition

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

TryCreate(string, RegexFlags, Regex?, string?)

Creates a regular expression without throwing for a pattern that is not valid.

public static bool TryCreate(string pattern, RegexFlags flags, out Regex? regex, out string? error)

Parameters

Name Type Description
pattern string The pattern.
flags RegexFlags The flags.
regex Regex? The regular expression, or null.
error string? Why the pattern was refused, or null.

Returns

bool

true when the pattern is valid in the grammar of its flags and not over a limit of size.

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