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].