Edit

Improve regex performance with .NET 5+

Cause

Regex performance has been significantly improved in .NET 5 and above. Applications that utilize a large amount of Regex processing can see improved performance by switching to .NET 5+.

Performance insight description

Significant improvements to the .NET Regex implementation have been completed in .NET 5+. Detailed descriptions of the improvements can be found on the following .NET blogs.

By testing your regex pattern against strings with BenchmarkDotNet, you can get insights into potential performance improvements.

How to investigate a warning

For .NET Framework apps, click on the How to update link to go to the .NET upgrade assistant, which will help migrate your project to .NET 5+. Also, please be aware that some technologies are unavailable in .NET 5+ and require more effort to update. For details, see .NET Framework technologies unavailable on .NET Core and .NET 5+.

For .NET Core apps, the process is simpler; download and install the .NET SDK version you want to use and update the target framework of your application.

Make sure your app's deployment environment has the corresponding .NET runtime version installed to prevent incompatibility issues.