The latest release of Microsoft’s. NET 7, the next edition of its software development platform, includes improvements for functioning with regular expressions and caching.
The fourth preview of.NET 7 was published on May 10 and is available for download from the Microsoft.NET website. The production release date is set for November.
Microsoft.NET Preview 4 includes the last of the planned APIs, which bring span-type support to the Regex (regular expressions) library. The updates include support for matching with ReadOnlySpan<char> inputs and an overhaul of the RegexOptions handling. IgnoreCase. Among the new span-based APIs are:
- Regex.IsMatch(ReadOnlySpan<char> input)
This signifies if a match is found in the input span by the regular expression.
- Regex.Count(ReadOnlySpan<char> input)
which finds all occurrences of a regular expression in an input string and returns the number of matches
- Regex.EnumerateMatches(ReadOnlySpan<char> input)
which searches an input span for regex occurrences and returns a ValueMatchEnumerator to iterate over the matches lazily.
Preview 4 adds metrics support for IMemoryCache. MemoryCacheStatistics, which contains cache hit, miss, estimated size, and count for IMemoryCache, and GetCurrentStatistics, which returns an instance of MemoryCacheStatistics or null when the TrackStatistics flag is not enabled, are the key APIs being introduced.