C# Regex Performance very slow

前端 未结 3 513
醉梦人生
醉梦人生 2020-12-29 08:53

I am very new in regex topic. I want to parse log files with following regex:

(?
3条回答
  •  庸人自扰
    2020-12-29 09:43

    Your regex can be optimized to:

    (?

    using negated char class instead of lazy quantifiers. It reduce backtrack. Regex101 went from 316 steps to 47 with this change. Combine it with RB.'s answer and you should be fine

提交回复
热议问题