-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Labels
area-System.Text.RegularExpressionsuntriagedNew issue has not been triaged by the area ownerNew issue has not been triaged by the area owner
Description
I'm trying to validate a regex pattern but I can't catch System.Text.RegularExpressions.RegexParseException
since it's internal
.
I can solve it by using pattern matching but it feels like a bodge:
private static bool IsValidRegex(string pattern)
{
if (string.IsNullOrEmpty(pattern))
{
return false;
}
try
{
Regex.Match(string.Empty, pattern);
}
catch (Exception ex)
when (ex is ArgumentException)
{
return false;
}
return true;
}
Metadata
Metadata
Assignees
Labels
area-System.Text.RegularExpressionsuntriagedNew issue has not been triaged by the area ownerNew issue has not been triaged by the area owner