Complexity of Regex substitution

前端 未结 8 1317
傲寒
傲寒 2020-12-01 16:58

I didn\'t get the answer to this anywhere. What is the runtime complexity of a Regex match and substitution?

Edit: I work in python. But would like to know in genera

8条回答
  •  不思量自难忘°
    2020-12-01 17:27

    In python's re library, even if a regex is compiled, the complexity can still be exponential (in string length) in some cases, as it is not built on DFA. Some references here, here or here.

提交回复
热议问题