I have the following regex:
var regex = new Regex(
@\"^ActiveMQ[\\d\\.-]*$\",
RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOpt
RegexOptions.Compiled
is not implemented in .NET Core 2.0, but is implemented in .NET Core 2.1.
Compilation involves initial overhead, and for certain usage patterns this overhead outweighs the gains of compiled regex.
My case is somewhat complex, and it seems like there might be a bug in .NET, because even with a proper benchmark (with warm-up), Compiled
mode is slower. See details in Corefx issue: https://github.com/dotnet/corefx/issues/30131