Regex slow on Windows Server 2008

前端 未结 3 1093
你的背包
你的背包 2021-01-13 06:53

I have a situation where my regular expressions compile extremely slowly on Windows Server 2008. I wrote a small console application to highlight this issue. The app gener

3条回答
  •  情书的邮戳
    2021-01-13 07:28

    I found a solution, given not the correct one, but perfect in my case. For some reason if I leave out the RegexOptions.Compiled flag, the Regex is much, much faster. I even managed to execute the Regex on 100 long phrases in under 65 milliseconds on the 2008 server.

    This must be a bug in the .net lib as the uncompiled version is supposed to be much slower than the compiled version. Either way, under 1 millisecond per check is very much acceptable for me :)

提交回复
热议问题