Tips on making regex more performant?
Gary Willoughby
dev at kalekold.net
Thu Jun 20 01:06:43 PDT 2013
> I'm working with some string-heavy applications so I was
> curious about this myself. I'm new to D, but I did some heavy
> data analysis on chat files a while back.
>
> Not knowing anything about your data or what other queries you
> might want to do on it, matching the first part of the string
> with std.algorithm.startsWith() and splitting the line on a
> delimiter outperforms regex matching on my admittedly arbitrary
> test code.
This is the approach i used and it's very very fast. Using
std.algorithm.startsWith() and simple delimiter based string
slicing i've solved it. It's so fast there is hardly any slow
down.
As a side note, i also use regex matching for the same data in
debug blocks to assert the slicing method matches what i would of
got from the regex, which is nice.
More information about the Digitalmars-d-learn
mailing list