Performance and practice of lazy regex?

后端 未结 3 2079
轮回少年
轮回少年 2021-01-14 07:03

I read on the internet i should avoid lazy regex because of \'worse\' performance and \'bad\' practice. I never seen an example of either. I havent heard of an app

3条回答
  •  执念已碎
    2021-01-14 07:25

    Your regex should fit your problem. I have seen cases where a lazy regex performed significantly worse than a greedy regex, as well as the other way around. There is no universally "better" way to do it. Most important is that the regex returns the expected results. After you get that down, you can tweak it for speed and profile the different versions to get an accurate speed comparison.

提交回复
热议问题