Sorry not helpful for your situation exactly, but I don’t know about regex
being easier to read than an old C style method.

On Sat, 22 Jan 2022 at 11:49, Greg Keogh <gfke...@gmail.com> wrote:

> Folks, I have to parse just over a million lines of text as quickly as
> possible. I'm using a Regex instance with a simple pattern (no backtrack or
> the like) and it's taking from 1 to 2 seconds, which my colleague says is
> too slow.
>
> Since it's a .NET 6 library I was keen to use the Span<> overloads of
> Regex.Match which should perform much better due to reduced allocations,
> but I can't find them. I know there was a big release of Span overloads
> recently, but didn't it make it into Regex?
>
> FYI -- My colleague used to parse the lines the old C-style way using a for
> (int =0; i<line.Length; i++) and looking for delimiters and *eating* 
> substrings
> as he went. That 1970s style code was hard to read, but it performed about
> 10x faster than a Regex. I thought my demo with a Regex.Match and just a
> few lines of code would be faster, but now I have egg on my face. That's
> why I was looking for the Span overloads to save my reputation.
>
> *Greg K*
>

Reply via email to