Balancing groups in variable-length lookbehind [duplicate]

I think I got it. First, as I mentioned in one of the comments, (?<=(?<A>.)(?<-A>.)) never matches. But then I thought, what about (?<=(?<-A>.)(?<A>.))? It does match! And how about (?<=(?<A>.)(?<A>.))? Matched against “12”, A is captures “1”, and if we look at the Captures collection, it is {“2”, “1”} – first two, then one … Read more