I found out that Regex can be accelerated by a factor of about two
new Regex(@"\n", RegexOptions.Compiled|RegexOptions.Multiline);
you can speed up by using:
new Regex(@"^.*?$", RegexOptions.Compiled|RegexOptions.Multiline);
But admittedly, nothing beats the native methods (IndexOf).
My statement above is wrong: I did compare "$" (and not
"\n") against "^.*?".
The measurments show that "\n" is the fastest of all Regex matches, while "$" is the slowest (5 times slower than "\n"...!).
That's a real surprise to me.
|Regex Match||[ms] for 2.500.000 lines||RegexOptions|
As a comparison: IndexOf('\n') only takes 237 [ms].
I feel comfortable on a variety of systems (UNIX, Windows, cross-compiled embedded systems, etc.) in a variety of languages, environments, and tools.
I have a particular affinity to computer language analysis, testing, as well as quality management.
More information about what I do for a living can be found at my LinkedIn Profile
and on my company's web page