(Jul-25-2023, 11:07 AM)deanhystad Wrote: I'm pretty sure you saw the explanation here:
https://stackoverflow.com/questions/2638...n-in-regex
I thought it was pretty good.
Hi!
Yes, I came across that at some point. However, what I don’t understand is why we need the closing bracket in the character group. Why can’t the regex be
/{(?:[^{]|(?R)*)/}
? Aren’t we starting a recursive call every time we encounter a closing bracket as well? Why is that desired? Shouldn’t we start a recursive call only when we find an opening bracket and expect it to be matched by the \}
part of the regex? I can’t understand why the regex with the closing bracket in the character group does not lead to infinite recursion, since, when we encounter the closing bracket, we make a recursive call, and that closing bracket is not matched again, leading to a new recursive call and so on. What am I missing here?Thanks a lot for replying.