static vs. instance versions of Regex.Match in C#
c#, performance, regex
Solution
One of the regular expression optimization recommendations in the following link: Regular Expression Optimization by Jim Mischel
For better performance on commonly used regular expressions, construct a Regex object and call its instance methods.
The article contains interesting topics such as caching regular expressions and compiling regular expressions along with optimization recommendations.
Problem
I've noticed some code that uses the static method: ``` Regex.IsMatch([someRegexStr], [someInputStr]) ``` Is it worth replacing it with the instance method? Like: ``` private readonly Regex myRegex = new Regex([someRegexStr]); ... myRegex.IsMatch([someInputStr]); ```