I was under the impression that the ? at the end of .+? makes it be "not greedy" and allows the conditional at the end to be matched, but now I'm confused. I can use the exact expression without the conditional at the end, and with .+ instead of .+? and the regexp works correctly. So what is the ? in .+? doing?