Why is my regex so much slower compiled than interpreted?

前端 未结 5 698
花落未央
花落未央 2021-02-18 18:17

I have a large and complex C# regex that runs OK when interpreted, but is a bit slow. I\'m trying to speed this up by setting RegexOptions.Compiled, and this seems

5条回答
  •  不知归路
    2021-02-18 19:07

    Try using Regex.CompileToAssembly, then link to the assembly so that you can construct the Regex objects. RegexOptions.Compiled is a runtime option, the regex would still get re-compiled every time you run the application.

提交回复
热议问题