swzoh wrote:
> So, it's not easy at all without impacting hard the performance as
> suspected. I was curious how it could detect \r\n before \r then. I
> thought it might be something like "[^\r]|\r(?!\n)" which would not
> impact performance much as most regex engines use short-cut
> evaluation. The natural generalization of it to CRLF might be
> [^\r\n]|\r(?!\n)|(?<!\r)\n
> 
> However, it would take twice more time than the first one, I suppose.
> What do you think about it?

If you're curious, benchmark it and you'll see how slow your expressions
are. In general I do favor using expressions to detect CRLF instead of
changing the meaning of newline... this way you won't have to rewrite
your expressions if newline-is-crlf isn't available for some reason
(it's far from ubiquitous).

Reply via email to