"Optimizing" concurrent regexes (opens in new tab)
I am looking into some regex work, and I ran into a performance problem. I need to run a particular regex over a large number (millions) of strings. That caused my spidey sense to… tingle. The code in question looked something like this:long matches = CountMatchingEntries(new Regex(@"\s+user id\s+"));Creating a regex for each invocation is… expensive. That is why we have the RegexOptions.Compiledflag, after all. And the Regex class is thread-safe, so I did the equivalent of this code:// class...
Read the original article