In the case of this simple regex
pattern = re.compile(r"(.*)*A")
which is immediately compiled, the search time grows exponentially with string length. Is this an expected behavior of python's re
library? I would expect that applying a compiled regex on a string should result in linear performance in string length.
pattern.search("x"*23)
1 second.
pattern.search("x"*24)
2 seconds.
pattern.search("x"*25)
4 seconds.
etc.
I tried both py3.7 and 3.8 and even 2.7, same results. However, I couldn't see this problem in applying the same regex from command line in sed.