[Analyzer]: Regex.Match(...).Success to Regex.IsMatch #111238
Labels
api-ready-for-review
API is ready for review, it is NOT ready for implementation
area-System.Text.RegularExpressions
code-analyzer
Marks an issue that suggests a Roslyn analyzer
code-fixer
Marks an issue that suggests a Roslyn code fixer
I see a non-trivial amount of code that does
Regex.Match(...).Success
rather thanRegex.IsMatch(...)
. The latter is functionally equivalent but more efficient, as it doesn't need to compute full match boundaries, doesn't need to compute capture groups, and doesn't need to allocate a Match object and supporting data structures. We should have an analyzer that looks for the former and a fixer that translates it into the latter. It should apply to both instance and static methods, everywhere there's a Match overload with arguments that have an exactly corresponding IsMatch overload.The text was updated successfully, but these errors were encountered: