php – Why is this regex reaching backtrack limit

After reading a lot how to optimize my regex, I discovered ?> which supposedly helps preventing unnecessary backtracking.

So I have this regex:

aaa(?>.{1,5000}?bbb).{1,5000}?(?=ccc|$)

For some reason, when I remove the ?> (regex below) I get no more backtracking error limit reached.

aaa.{1,5000}?bbb.{1,5000}?(?=ccc|$)

How is it possible? If the error happened without ?> I could understand why, but I cant understand how using it, causes the backtrack error.

Read more here: Source link